Performing Out-of-Band Swaps
Most of the time, the HTML returned by endpoints is swapped into the DOM at the location specified by the hx-target attribute (or its default value). But sometimes it’s useful for an endpoint to return multiple HTML fragments that are each inserted at different locations in the DOM. Out-of-band swaps enable this.
The HTML fragment to be inserted at the hx-target location can be considered an in-band swap. All the others must use out-of-band swaps by including the hx-swap-oob attribute.
Any number of HTML elements (each representing a fragment) can be returned as long as at most one of them lacks the hx-swap-oob attribute. The one element that lacks the hx-swap-oob attribute will be swapped in using the default behavior ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access