gray-morning-3453
04/19/2023, 5:08 AMhtmx.on('htmx:afterSwap', function(event) {
// Get all the newly added buttons in the swapped HTML
var newButtons = event.detail.querySelectorAll('button');
// Attach the same event handler function to each new button
for (var i = 0; i < newButtons.length; i++) {
newButtons[i].addEventListener('click', myEventHandlerFunction);
}
});
function myEventHandlerFunction(event) {
// Your event handler code here
}
sparse-musician-64201
04/19/2023, 11:06 AMnumerous-agent-22346
04/19/2023, 11:15 AMnumerous-agent-22346
04/19/2023, 11:23 AMon click from -selector- in -selector- call myEventHandler(event)
sparse-musician-64201
04/19/2023, 11:25 AMfuture-plumber-63481
04/19/2023, 12:14 PMhx-trigger="search from:input, submit"
#1 and #3 work fine. #2 causes the form to be submitted twice. Can anyone help me work out why?sparse-musician-64201
04/19/2023, 12:15 PMsparse-musician-64201
04/19/2023, 12:16 PMfuture-plumber-63481
04/19/2023, 12:19 PMsearch
event I have to then explicitly include the submit
event.future-plumber-63481
04/19/2023, 12:23 PMsubmit, search queue:none
seems to do it.mysterious-toddler-20573
04/19/2023, 2:07 PMautofocus
attribute from standard HTML: https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L861numerous-agent-22346
04/19/2023, 2:16 PMmysterious-toddler-20573
04/19/2023, 2:39 PMmysterious-toddler-20573
04/19/2023, 2:39 PMmysterious-toddler-20573
04/19/2023, 2:41 PMmysterious-toddler-20573
04/19/2023, 3:17 PMgeneral
channels in my liferefined-waiter-90422
04/19/2023, 3:48 PM<script>$on...
at the bottom of your post which is kinda nice.magnificent-boots-1658
04/19/2023, 4:08 PMmysterious-toddler-20573
04/19/2023, 4:35 PMquick-lamp-41411
04/19/2023, 8:31 PMafterSettle
events on the document
but some of the events I'd like to handle are happening on elements that have been removed from the DOM so the event isn't bubbling up. Is there any easy way to resolve this?thousands-planet-99021
04/19/2023, 10:20 PMnarrow-midnight-94579
04/19/2023, 10:33 PMnarrow-midnight-94579
04/19/2023, 10:35 PMmysterious-toddler-20573
04/19/2023, 10:43 PMHX-Retarget
response header: https://htmx.org/reference/#response_headersmysterious-toddler-20573
04/19/2023, 10:44 PMthousands-planet-99021
04/19/2023, 11:01 PMmysterious-toddler-20573
04/20/2023, 12:33 AMsparse-musician-64201
04/20/2023, 10:20 AMsparse-musician-64201
04/20/2023, 10:20 AM