Closed robingram closed 4 months ago
Hey @robingram, thanks!
Yes, that's supported although not documented yet. This should work:
<div data-controller="foo">
<%= combobox_tag :movie, [options], data: { action: "hw-combobox:selection->foo#doSomething" } %>
</div>
hw-combobox:selection
is emitted when the combobox is closed and the selection is finalized.
hw-combobox:preselection
is emitted when the active option changes due to navigating with the keyboard or typing in the combobox.
You can use either, but my example above uses hw-combobox:selection
Finally, hw-combobox:removal
is emitted in multiselect comboboxes only (not documented yet) when the user removes a selection chip.
Let me know if you run into trouble! Closing for now.
Thanks for the super speedy reply. That's working with hw-combobox:selection
. 👍
This is a super clean approach, thank you so much for the awesome lib. Can this be added to the docs please? It takes a while to find the closed issue and figure it out.
Thanks for your work on this, it looks like it will become a really nice component.
Can I ask if it is possible at the moment to call an action on another stimulus controller when an item is selected from the list? I've tried setting a
data
attribute directly on the combo box and also viainput: ...
but neither seems to be setting theaction
. Maybe that is still in the pipeline. :)Thanks.