I would like to use jquery instead of prototype and I am a bit lost to convert this observe_field in jquery.
<%=text_field_tag :section %>
<%= observe_field(:section,
:frequency => 0.1,
:update => "article_list",
:with => 'section',
:url =>{ :action => :get_article_list }) %>
Here is my start:
$(document).ready(function() {
$("#section").bind("keyup", function() {
var url = '/catalogs/get_article_list';
$.get(url, function(html) {
$("#article_list").html(html);
});
});
});
I read this post but I think I’m missing something.
Would appreciate any explanations.
Thanks.
An observer, observers an event on any input element, when the event occurs it send a request to given url using ajax and update response on page in given element.
Here you got the event observing very well, so you have written the code to bind the keyup event of section element.
Now when the keyup event triggers you need to make an ajax request to server.
Hope this helps you to understand it.