我正在尝试对我的应用程序的select box.For进行onchange调用,我正在使用前面提到的jquery.js和rails.js来使用UJS。但是,生成的代码是针对Prototype的,而不是针对jquery ajax调用的。我的代码如下所示:
<%= select_tag :category,
options_for_select(
Category.find(:all,:select=>"name,id").collect{|c| [c.name,c.id]}),
:onchange => remote_function(:url => {:controller => "posts",
:action => "filter_post",
:filter =>"category"},
:with=>"'category_id=' + $('#category').val()") %>
由此生成的代码为:
new Ajax.Request('/posts/filter_posts?filter=category', {asynchronous:true, evalScripts:true,
parameters:'category_id=' + $('#category').val() + '&authenticity_token=' +
encodeURIComponent('CCyYj1wqXtddK6pUV6bAxw0CqZ4lbBxDGQHp13Y/jMY=')})
https://stackoverflow.com/questions/3332474
复制相似问题