From 488516c829a9ce226d525504ae6992d3c7d73afc Mon Sep 17 00:00:00 2001 From: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:26:17 +0200 Subject: [PATCH] Document parameter --- www/content/api.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/content/api.md b/www/content/api.md index a5822e47a..eba8a71b6 100644 --- a/www/content/api.md +++ b/www/content/api.md @@ -316,12 +316,14 @@ Adds an event listener to an element * `eventName` - the event name to add the listener for * `listener` - the listener to add +* `options` - [options](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#options) to add to the event listener (optional) or * `target` - the element to add the listener to * `eventName` - the event name to add the listener for * `listener` - the listener to add +* `options` - [options](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#options) to add to the event listener (optional) ##### Example @@ -331,6 +333,9 @@ or // add a click listener to the given div var myEventListener = htmx.on("#my-div", "click", function(evt){ console.log(evt); }); + + // add a click listener to the given div that should only be invoked once + var myEventListener = htmx.on("#my-div", "click", function(evt){ console.log(evt); }, { once: true }); ``` ### Method - `htmx.onLoad()` {#onLoad}