Last active
August 21, 2025 07:52
-
-
Save wjkoh/152adbad3acf30d7d4f9b01f72748a37 to your computer and use it in GitHub Desktop.
HTMX + Alpine.js: Displaying HTTP Errors Using the HTML <dialog> Element
This file contains hidden or 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
| <!-- Copy and paste the following to every html file. --> | |
| <div x-data="{ open: false, title: '', content: '' }" | |
| x-on:htmx:response-error.window="title = $event.detail.xhr.statusText; content = $event.detail.xhr.responseText; open = true"> | |
| <dialog x-bind:open="open"> | |
| <article> | |
| <h2>Error: <span x-text="title"></span></h2> | |
| <p><code x-text="content"></code></p> | |
| <footer> | |
| <button x-on:click="open = false">OK</button> | |
| </footer> | |
| </article> | |
| </dialog> | |
| </div> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
