11

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>
irahorecka
  • 1,447
  • 8
  • 25

1 Answers1

19

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>
irahorecka
  • 1,447
  • 8
  • 25