Closed 34code closed 2 years ago
You can add any extra param that you need to the data-autocomplete-url-value
attribute:
<div data-controller="autocomplete" data-autocomplete-url-value="/products?category_id=3">
...
</div>
You might need to change the autocomplete url dynamically. You can do that with another stimulus controller that listens to changes on your select element and then updates the url with the selected value. Or server side with a turbo stream update if you're using Turbo.
Thanks thats a good idea!
I have a select dropdown param and a textbox for autocomplete. Autocomplete logic depends on knowing the which category the user wants to autocomplete from (from select dropdown)