Confusion over htmx events #3529
angrytongan
started this conversation in
General
Replies: 1 comment 4 replies
-
|
When htmx inserts content it can insert multiple nodes in multiple locations relative to the target based on the swap style like afterbegin. So its not practical to provide the actual swapped in target elements and you only have access to the detail.target which is the elt it was placed near (or inside for innerHTML). And with outerHTML the target is removed from the DOM and replaced with one or more nodes so it is even harder to track. the detail.elt is always actually the elt that makes the request and so in your example detail.elt should be a button and detail.target should be the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The documentation for htmx:afterSwap states that
detail.eltis the swapped in element, anddetail.targetis the target of the request.The sample below prints both of these elements on a swap. In this example, both are the same; I was expecting
detail.eltto show the returned list element.Can anyone point me at where I'm going wrong?
Beta Was this translation helpful? Give feedback.
All reactions