Debian Codegraph @

www/src/content/reference/03-events/06-htmx-after-swap.md

raw symbols SCIP
1 ---
2 title: "htmx:after:swap"
3 description: "After content is swapped into DOM"
4 ---
5
6 The `htmx:after:swap` event fires after new content has been swapped into the DOM.
7
8 ## When It Fires
9
10 Immediately after the DOM swap operation completes, before elements are processed.
11
12 ## Event Detail
13
14 - `ctx` - Request context including swap details
15
16 ## Example
17
18 ```javascript
19 htmx.on('htmx:after:swap', (evt) => {
20 console.log('Content swapped into:', evt.detail.ctx.target);
21 // Initialize widgets, scroll to position, etc.
22 });
23 ```
24
25 The new content is in the DOM but may not be fully processed by htmx yet.