Skip to content

Events ​

All events are dispatched on the native <select> and bubble, so you can listen on the select, its form, or the document.

Native events ​

Every change made by the user, or by a method without silent: true, fires input and then change, exactly like a native select. Existing code and htmx hx-trigger="change" keep working.

js
document.querySelector('#status').addEventListener('change', (event) => {
  console.log(event.target.value);
});

flowselect events ​

Each is a CustomEvent. event.detail.instance is the instance and event.detail.value the current value.

EventWhenExtra detail
flowselect:initThe instance was created
flowselect:openThe list opened
flowselect:closeThe list closed
flowselect:changeThe value changed, after input and changeitems: the chosen items
flowselect:searchThe search text changed while openquery
flowselect:loadRemote results arrivedquery, page, items
flowselect:errorA remote request or create function failederror, query, page
flowselect:createA new option was createditem
flowselect:destroyThe instance was destroyed
  1. Events appear here.
js
document.addEventListener('flowselect:change', (event) => {
  const { instance, value, items } = event.detail;
  console.log(instance.element.name, value, items);
});

With htmx ​

html
<select name="person" data-flow-select data-fs-url="/api/people"
        hx-get="/preview" hx-trigger="flowselect:change" hx-target="#preview"></select>

Released under the MIT License.