HTMX Integration
For requests carrying the HX-Request header, all queued alerts are written to the HX-Trigger
response header under the ux-sweet-alert:alert:added event name. An existing HX-Trigger header is
merged, not overwritten.
Automatic dispatch
HX-Trigger: {"ux-sweet-alert:alert:added":{"alerts":[{"title":"Saved","icon":"success"}]}}
HTMX turns this header into a browser event, and the SweetAlert Stimulus controller already listens for that event name.
Requirements
- HTMX must be present on the page.
ux_sweet_alert_scripts()must still be rendered so the Stimulus controller can react to the dispatched browser event.
When to prefer HTMX
Use this path when your application already leans on HTMX request/response patterns.