htmx:after:swap
Fires after DOM update
The htmx:after:swap event fires after new content has been swapped into the DOM.
When It Fires
Immediately after the DOM swap operation completes, before elements are processed.
Event Detail
-
ctx- Request context including swap details
Example
htmx.on('htmx:after:swap', (evt) => {
console.log('Content swapped into:', evt.detail.ctx.target);
// Initialize widgets, scroll to position, etc.
}); The new content is in the DOM but may not be fully processed by htmx yet.
Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/events/htmx-after-swap/