在添加到will_paginate ajax_paginationг之后,复选框上的pdate只能在第一页上工作。_page.html.erb:
<%= ajax_links :section_id => "page" do %>
<%= will_paginate @jquestions %>
<% end %>
<%= ajax_loadzone do %>
<% @jquestions.each do |jquestion| %>
<h2><%== (Dquestion.find(jquestion.dquestion_id)).question_text %> </h2> </br>
<%= render (Janswer.where(jquestion_id: jquestion.id)) %>
</br>
<% end %>
<% end %>janswers.js.coffee:
jQuery.fn.submitOnCheck = ->
@find('input[type=checkbox]').click ->
$(this).parent('form').submit()
this
jQuery ->
$('.edit_janswer').submitOnCheck()和表格:
<%= form_for(janswer, remote: true) do |f| %>
<%= f.check_box :truanswer %> <%== (Danswer.find(janswer.danswer_id)).answer_text %>
<% end %>如何决定这个问题?
发布于 2013-07-05 01:53:11
你真的需要ajax gem吗?
Ryan Bates展示了如何简化解决方法:使用少量http://railscasts.com/episodes/174-pagination-with-ajax代码的jquery
我以为你是完全重新加载页面和dropp绑定。你必须重置它们或者使用类似的东西:
$(document).on 'click', 'input[type=checkbox]', ()->
//your stuffhttp://api.jquery.com/on/请在此处查看说明
https://stackoverflow.com/questions/17467920
复制相似问题