Debian Codegraph @

www/src/content/reference/01-attributes/22-hx-confirm.md

raw symbols SCIP
1 ---
2 title: "hx-confirm"
3 description: "Shows a confirmation dialog before the request"
4 ---
5
6 The `hx-confirm` attribute allows you to confirm an action before issuing a request. This can be useful
7 in cases where the action is destructive and you want to ensure that the user really wants to do it.
8
9 ## Syntax
10
11 ```html
12 <button hx-delete="/account" hx-confirm="Are you sure?">Delete Account</button>
13 ```
14
15 Here is an example:
16
17 ```html
18 <button hx-delete="/account" hx-confirm="Are you sure you wish to delete your account?">
19 Delete My Account
20 </button>
21 ```
22
23 ## Event details
24
25 The event triggered by `hx-confirm` contains additional properties in its `detail`:
26
27 * triggeringEvent: the event that triggered the original request
28 * issueRequest(skipConfirmation=false): a callback which can be used to confirm the AJAX request
29 * question: the value of the `hx-confirm` attribute on the HTML element
30
31 ## Notes
32
33 * `hx-confirm` uses the browser's `window.confirm` by default. You can customize this behavior as
34 shown in the [Dialogs](/patterns/display/dialogs) pattern.
35 * a boolean `skipConfirmation` can be passed to the `issueRequest` callback; if true (defaults to false), the
36 `window.confirm` will not be called and the AJAX request is issued directly