HTMX: render element¶
Available since: 3.1.3
Build an HTMX-enabled element with a configurable request method, trigger, swap, target and other common HTMX attributes.
Building HTMX interactions
This action builds a single element carrying the HTMX attributes you
configure (request method and URL, trigger, swap strategy, target, and
more). It attaches the core/drupal.htmx library automatically. Use it for
click-to-load fragments, infinite scroll, and similar interactions. For a
region that refreshes on a timer, use the
HTMX: poll region action
instead. See
Building HTMX-powered interfaces with ECA.
Fields¶
Request method-
The HTTP method HTMX uses for the request.
When using the "Defined by token" option, make sure there is a token with this name: eca_htmx_element_method Request URL-
The URL HTMX requests. Leave empty to request the current URL. Internal paths start with a slash, for example /node/1.
This field supports tokens. Trigger-
The HTMX trigger definition, for example click, change or every 5s.
This field supports tokens. Swap strategy-
The HTMX swap strategy, for example innerHTML, outerHTML or beforeend.
This field supports tokens. Target-
Optional CSS selector identifying the element that receives the swapped content.
This field supports tokens. Select-
Optional CSS selector for the content to select from the response.
This field supports tokens. Push URL-
Optional URL to push to the browser history, or true/false to enable or disable pushing the fetched URL.
This field supports tokens. Confirm message-
Optional message to show in a confirmation dialog before the request is issued.
This field supports tokens. Indicator-
Optional CSS selector of the element that receives the htmx-request class during the request.
This field supports tokens. Values-
Optional values to add to the request parameters, in YAML format, for example key: "[token]".
This field supports tokens. Boost-
When enabled, anchors and forms inside the element are progressively enhanced to use AJAX.
Request only the main content-
When enabled, the request is sent with the Drupal "only main content" hint, so the response is the minimal HTMX render rather than a full HTML page.
Initial content-
The markup shown inside the element before any swap occurs.
This field supports tokens. Wrapper tag-
The HTML tag of the element, for example div, button or span.
When using the "Defined by token" option, make sure there is a token with this name: eca_htmx_element_wrapper_tag Machine name-
Optionally define a machine name of this render element. It will be made available under that name in the render array of the current event in scope. Nested elements can be set with using "][" brackets, for example details][title.
This field supports tokens. Token name-
Optionally define a token name of this render element. It will be made available under that token name for later usage. Please provide the token name only, without brackets.
Element weight-
Optionally specify an element weight. The lower the weight, the element appears before other elements having a higher weight.
Build mode-
When using the "Defined by token" option, make sure there is a token with this name: eca_htmx_element_mode