htmx:before:request
Fires immediately before fetch()
The htmx:before:request event fires immediately before the fetch() call is made.
When It Fires
Right before the network request is sent, after all configuration and validation.
Event Detail
-
ctx- Request context object with final request configuration
Example
htmx.on('htmx:before:request', (evt) => {
console.log('Sending request to:', evt.detail.ctx.request.action);
// Show loading indicator
}); Cancel this event to prevent the request from being sent.
Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/events/htmx-before-request/