samedi 19 mars 2016

catch params of check box pagination using jquery datable gem

unable to catch check_box params of remaining pages i am getting only 1st page params please help me

I am able to catch only submit page params

my view

 <table id="associations" class="table table-striped table-bordered ">
      <thead>
      <th>Check</th>
      <th>Logo</th>
      </thead>
      <tbody>
      <% @benefits.each do |benefit|%>
          <%@selected_benefits = AssocBenefit.where(:benefit_id=>benefit.id, :association_id => @association.id, :status => true).first%>
          <tr>
            <td>
              <%#= check_box_tag :car, :value => 2, :checked => (f.sex == 2) %>
              <%if @selected_benefits.present?%>
                  <%= hidden_field_tag 'benefits1[]', benefit.id %>
                  <%= check_box_tag 'benefits[]', benefit.id, :checked => (benefit.id == @selected_benefits.id)%>
                  </td>
              <%else%>
                  <%= hidden_field_tag 'benefits1[]', benefit.id %>
                  <%= check_box_tag 'benefits[]', benefit.id%></td>
              <%end%>
              <td><%= image_tag benefit.image(:thumb) %></td>
              <td><%= benefit.benefits_name%></td>

      <%end%>
      </tbody>
    </table> 

My controller

        def save_choose_benefits
   assoc_benefits = AssocBenefit.where.not(:benefit_id =>  params[:benefits]).all if params[:benefits1]
      assoc_benefits.delete_all
       unless params[:benefits].blank?

    params[:benefits].each do |d|
    ss= AssocBenefit.where(:benefit_id => d).first
    if ss.blank?
         assoc_benefits = AssocBenefit.new(:benefit_id => d ,:association_id => params[:association_id], :status=>"true")
      if assoc_benefits.valid?
        assoc_benefits.save
      end
      end
     end
      end
redirect_to associations_list_path ,:notice => "Successfully applied"

 end

here is my script

       <script>
    $(document).ready(function()
       {
           $('#associations').dataTable();
       }
      );
    </script>

I installed gem jquery-datatables and also jquery-turbolink to pass params but there is no luck to pass params of second page and etc..

please help me out of these solution

thanks

Aucun commentaire:

Enregistrer un commentaire