HX-Retarget
Overrides swap target from server
The HX-Retarget response header overrides the element that will receive the swapped content, replacing whatever hx-target was set on the triggering element.
Syntax
HX-Retarget: #new-target
The value is a CSS selector for the new target element.
Redirect a form submission result to a different container:
return Response(
content,
headers={'HX-Retarget': '#notifications'}
) Notes
- Overrides
hx-targeton the source element - Evaluated after the response is received, before swapping
See Also
Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/headers/HX-Retarget/