Getting Started
Core Concepts
Control
Interactivity
Performance
Pushing Data
HTMX Extensions
Miscellaneous
Configuration
Mutation Error
The 'mutation-error' extension allows you to trigger an event when a request returns a >= 400 status code.
This is useful for things such as letting a child element (such as a button) inside a form know there was an error.
Example:
h.Form(
h.HxTriggerChildren(),
h.HxMutationError(
js.Alert("An error occurred"),
),
h.Button(
h.Type("submit"),
h.Text("Submit"),
),
)
Copy
1h.Form(
2 h.HxTriggerChildren(),
3 h.HxMutationError(
4 js.Alert("An error occurred"),
5 ),
6 h.Button(
7 h.Type("submit"),
8 h.Text("Submit"),
9 ),
10)
It can also be used on children elements that do not make an xhr request, if you combine it with the TriggerChildren extension.