2017-09-26 39 views
0

我有我的觀點我在哪裏出的所有記錄,我需要添加多個選擇複選框軌道,我這樣做以下列方式:選擇複選框通陣列上使用雷分頁

<%= form_tag("/user_selection", method: 'get', remote: true, class: "form-horizontal") do %><!--responde al index--> 

    <div class="rwd"> 
    <table class="table table-striped table-bordered table-condensed table-hover"> 
     <thead> 
     <tr> 
      <th>name</th> 
      <th>last name</th> 
     </tr> 
     </thead> 
     <tbody id="container_users"> 
      <%= render @users %> 

     </tbody> 
    </table> 
    <%= paginate @users, :param_name => 'users' %> 

    </div> 
    <%= submit_tag "send", data: { disable_with: 'sending...' } %> 
<% end %> 

部分用戶

<tr id="user_<%= user.Id %>"> 
    <td><%=user.try(:name)%></td> 
    <td><%=user.try(:lastname)%></td> 
    <td><%= check_box_tag "items[]", user.Id %></td> 
</tr> 

這樣我可以選擇多條記錄與發送的ID控制器,問題就來了,當我選擇的記錄,我去下一個頁面上,使用雷的頁面上,從路過的時候頁面上一頁的記錄不再被選中,就像y一樣你解決了嗎?

回答

0

1)。將所有選定的用戶保存到窗體的隱藏字段selected_user_ids。 Kaminari應該發送遠程請求並且只更新用戶的表格而不是整個頁面。在這種情況下,selected_user_ids將保留所有選擇的用戶。

第二種方式: 將所有選定的用戶保存到localStorage。在表單提交時,從localStorage提取所有用戶ID,並在隱藏字段和發送表單時保存它們。