I am using Ruby on Rails.
I want to create a filter field on a page such that whenever the input field’s value changes I filter a list shown below via ajax. (Exaclty like the Users search works in Stackoverflow)
For now, I made it run with a form_remote_tag containing a text_field_tag and a submit_tag, and it filters my list when I push the submit button. I would like to remove the submit button and execute the filtering every time the value of the text input changes. How can I trigger a form submit every time the text in an input field changes?
I tried inside my form
<%= text_field_tag (:filter), '' , :onchange => 'alert ('This is a Javascript Alert')' %>
just to get the onchange event, but somehow not even this alert appears…
Use observe_field helper with a single input, like the code bellow:
And then just write a controller that, given a param named ‘typed_filter’, renders the results, wich will be shown in the element with id ‘results’ (probably a div).