Except the AJAX forms and some link_to feature, one of my favorite features is AJAX HTTP request back to server when one of the forms input control content changed by user and lost focus. Such feature is very similar to ASP.NET AutoPostBack, which is very handy when you need user fill some content first before you can help them auto fill the rest.
The rails_ujs is simple to use, mainly three steps:
Declare text_field as remote.
Prepare the data in Rails server side
Although it’s very easy, but some time, you need additional field value to do the data preparation, but the jquery-ujs only can send back the triggered control value to server, then you have to add the custom events for data-remote request, here is how:
Then you can, from controller get additional field value via
The hack method not elegant as original jquery-ujs, so if you have more good methods, just comments.