function Htmx::trigger
Creates a `data-hx-trigger` attribute.
This attribute instructs HTMX when to trigger a request.
Used with an HTMX request attribute. Allows:
- An event name (e.g. “click” or “myCustomEvent”) followed by an event filter and a set of event modifiers
- A polling definition of the form every <timing declaration>
- A comma-separated list of such events.
Parameters
string|string[] $triggerDefinition: The trigger definition.
Return value
static Returns this object to allow chaining methods.
See also
https://htmx.org/attributes/hx-trigger/
File
-
core/
lib/ Drupal/ Core/ Htmx/ Htmx.php, line 812
Class
- Htmx
- Presents the HTMX controls for developers to use with render arrays.
Namespace
Drupal\Core\HtmxCode
public function trigger(string|array $triggerDefinition) : static {
if (is_array($triggerDefinition)) {
$triggerDefinition = implode(',', $triggerDefinition);
}
$this->createStringAttribute('hx-trigger', $triggerDefinition);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.