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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With