'Multiple triggers for HTMX?
Is it possible to enable multiple trigger types for HTMX? What I want to do is to trigger HTMX on either content change or page load. So far, if I include both trigger types in hx-trigger, only the first trigger is executed; so in the example below, HTMX is triggered only upon content change.
<select name="area" id="area" hx-post="/api/search" hx-trigger="change load" hx-target="#neighborhood" class="block">
<option>eby</option>
<option>nby</option>
<option>pen</option>
<option>sfc</option>
<option>scz</option>
<option>sby</option>
</select>
Solution 1:[1]
It's as simple as comma-separating your trigger types:
<select name="area" id="area" hx-post="/api/search" hx-trigger="change, load" hx-target="#neighborhood" class="block">
<option>eby</option>
<option>nby</option>
<option>pen</option>
<option>sfc</option>
<option>scz</option>
<option>sby</option>
</select>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | irahorecka |
