HTMX: set response header¶
Available since: 3.1.3
Set one of the HTMX HX-* response headers (e.g. redirect, location, push URL, refresh or trigger) on the current response. Reacts to a response event, for example the "Response created" event of the ECA Miscellaneous module or an ECA Endpoint response.
Runs on a response event
This action sets an HTMX HX-* header on the current response, so it must
run in response to a response event such as the
Response created event or an
ECA endpoint response.
The HX-Location header supports its full form through the additional
location fields (source, event, handler, target, swap, values, headers, and
select). See
Building HTMX-powered interfaces with ECA.
Fields¶
Response header-
The HTMX response header to set.
When using the "Defined by token" option, make sure there is a token with this name: eca_htmx_response_header_header Value-
The header value. For URL headers provide a URL (internal paths start with a slash); for the refresh header use true or false; for trigger headers provide the event name; for retarget/reswap/reselect provide the CSS selector or swap strategy. For the location header this is the path (URL).
This field supports tokens. Location: source-
The source element of the request.
This field supports tokens. Location: event-
An event that "triggered" the request.
This field supports tokens. Location: handler-
A callback that will handle the response HTML.
This field supports tokens. Location: target-
The CSS selector of the target for the swap.
This field supports tokens. Location: swap-
The swap strategy, for example innerHTML or outerHTML.
This field supports tokens. Location: select-
A CSS selector for the content to swap into the target.
This field supports tokens. Location: values-
A set of values to submit with the request, as a key-value list in YAML format. Example:
key: value. When using tokens, wrap them as a string. Example: id: "[node:nid]".
This field supports tokens. Location: headers-
Headers to submit with the request, as a key-value list in YAML format. Example:
X-Custom: value. When using tokens, wrap them as a string. Example: X-Custom: "[token]".
This field supports tokens.