[英]gem 'ajax_pagination' vs jquery function
在將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 %>
如何解決這個問題?
您真的需要Ajax寶石嗎?
Ryan Bates展示了如何輕松解決: http: //railscasts.com/episodes/174-pagination-with-ajax,jQuery代碼很少
我以為您已完全重載頁面和dropp綁定。 您必須重置它們或使用類似的方法:
$(document).on 'click', 'input[type=checkbox]', ()->
//your stuff
http://api.jquery.com/on/在此處查看說明
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.