htmx 4.0 is under construction — migration guide

htmx:after:restore

After preserved elements are restored

The htmx:after:restore event fires after elements marked with hx-preserve have been moved back into their original positions.

When It Fires

After a swap operation that includes preserved elements, once they’ve been restored to the new content.

Event Detail

  • ctx - Request context

Example

htmx.on('htmx:after:restore', (evt) => { console.log('Preserved elements restored'); // Re-attach listeners to preserved elements if needed });

Preserved elements maintain their state across swaps.