Sign in
Log inSign up
Avi Flombaum

6 likes

·

5.9K reads

3 comments

Matias H. Leidemer
Matias H. Leidemer
Feb 13, 2024

Hey there, Avi; thank you for sharing this post!

I was trying it on my machine, and as it turns out, we don't even need to create a custom stimulus controller.

All you need to do is set the form's data-turbo-frame="jobs" attribute and, instead of using the TurboVisit + FormData combo, call the form's requestSubmit() function.

<form data-turbo-frame="jobs" etc>
  <%= select_tag :category, etc, onchange: "this.form.requestSubmit()" %>
</form>

More info:

Let me know what you think, cheers!

1
·
·1 reply
Avi Flombaum
Avi Flombaum
Author
·Feb 13, 2024

Ya, you could bind the onchange event to each form field to then use requestSubmit or just wrap it all in a Stimulus controller. Thanks for adding to the article! <3

·
Stefanos N.
Stefanos N.
Aug 19, 2024

Hi Avi, thanks a lot for this, it's super helpful and extremely fast.

Another question I would have is how would you handle counters for these filters? Let's say we have counters next to each filter and on each filter selection, should update all the other filter counters

·