I want a rails method to be called automatically whenever the contents of a textfield is changed, or every n seconds. How can I do this? The method is on the object's model definition. Also, how can I get the content of the textfield?
Thanks.
I want a rails method to be called automatically whenever the contents of a textfield is changed, or every n seconds. How can I do this? The method is on the object's model definition. Also, how can I get the content of the textfield?
Thanks.
This will require using some javascript. I use the jQuery library to help me along. I would search the net ('Google') "rails jquery" for some tutorials.
Or if you prefer another library check out Best javascript libraries to work with rails?
Once you have your javsacript library in place you will need some sort of script to monitor the input. One way is to use a keyup
event to listen for activity. This script will then post your data to the server via ajax.