Last active
August 27, 2024 09:33
-
-
Save trey/d04adbcc234800e90ff2ea3db3adcb46 to your computer and use it in GitHub Desktop.
JavaScript confirmation message with Alpine.js and htmx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
https://alpinejs.dev/directives/on#prevent | |
https://github.com/alpinejs/alpine/issues/150#issuecomment-580452229 | |
--> | |
<form x-data action="/something" @submit.prevent="if (confirm('Are you sure?')) $el.submit()" method="post"> | |
<button aria-label="Delete this">[some icon]</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
https://htmx.org/attributes/hx-confirm/ | |
https://htmx.org/attributes/hx-delete/ | |
--> | |
<form action="/something" hx-confirm="Are you sure?" method="post"> | |
<button hx-delete="/something" aria-label="Delete this">[some icon]</button> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment