document.body.addEventListener('htmx:confirm', function(evt) { // 0. To modify the behavior only for elements with the hx-confirm attribute, // check if evt.detail.target.hasAttribute('hx-confirm') // 1. Prevent the default behavior (this will prevent the request from being issued) evt.preventDefault(); // 2. Do your own logic here console.log(evt.detail) // 3. Manually issue the request when you are ready evt.detail.issueRequest(); // or evt.detail.issueRequest(true) to skip the built-in window.confirm() });