0

除了 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 %>

如何决定这个问题?

4

1 回答 1

1

你真的需要ajax gem吗?

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/在这里查看描述

于 2013-07-04T17:53:11.223 回答