You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having this issue where I set 2 event listeners on an HTML node using hx-on. This is fine until I trigger completely unrelated request from a <button> which swaps some HTML into the DOM. It seems like the first of the 2 listeners on the <div> gets added again for each new node that is introduced. So I'll end up with many listeners on that <div>.
There's a couple ways I can get around this but I'm wondering if this isn't some bug within HTMX, it doesn't seem like desirable behaviour.
/dummy just returns "<div>" with status code 200. "custom-event-a" is the one that gets added multiple times, "custom-event-b" just gets added once. Same behaviour on Firefox & Chrome.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm having this issue where I set 2 event listeners on an HTML node using
hx-on
. This is fine until I trigger completely unrelated request from a<button>
which swaps some HTML into the DOM. It seems like the first of the 2 listeners on the<div>
gets added again for each new node that is introduced. So I'll end up with many listeners on that<div>
.There's a couple ways I can get around this but I'm wondering if this isn't some bug within HTMX, it doesn't seem like desirable behaviour.
Here is a minimum reproducible example:
/dummy
just returns "<div>" with status code 200. "custom-event-a" is the one that gets added multiple times, "custom-event-b" just gets added once. Same behaviour on Firefox & Chrome.UPDATE: I made a PR to fix this #1862
Beta Was this translation helpful? Give feedback.
All reactions