Rails 4、第一页后的Kaminari和Filterrific问题
Rails 4, Kaminari and Filterrific issue after first page
我在 rails 4 中遇到了这个问题,我有一个使用 gem kaminari 分页的列表,并使用 gem filterrific 按名称进行筛选。当页面刚加载时一切正常,但在我移动到另一个页面后过滤器不起作用,除非我在输入中单击 enter。
这是我的代码:
index.html.erb
<%= link_to 'Agregar Membresía', new_catalog_membership_path, class:"btn btn-primary btn-sm", style:"margin-bottom: 10px" %>
<div>
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Membresías Registradas</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="ibox-content">
<%= form_for_filterrific @filterrific do |f| %>
<%= f.text_field(:search_query, id:"filterrific_search_query", class: 'filterrific-periodically-observed form-control input-sm m-b-xs', name: "filterrific[search_query]",
placeholder: "Buscar membresía") %>
<% end %>
<%= render(
partial: 'catalog_memberships/list',
locals: { catalog_memberships: @catalog_memberships }
) %>
</div>
</div>
</div>
_list.html.erb
<div id="filterrific_results">
<% if catalog_memberships.count > 0 %>
<table class="footable table table-stripped">
<thead>
<tr>
<th width="50%">Nombre</th>
<th width="25%">Monto Total</th>
<th width="25%">Acciones</th>
</tr>
</thead>
<tbody>
<% catalog_memberships.each do |catalog_membership| %>
<tr>
<td><%= catalog_membership.nombre %></td>
<td><%= catalog_membership.monto_total %></td>
<td>
<%= link_to edit_catalog_membership_path(catalog_membership), class: "btn-white btn btn-xs" do %>
<i class="fa fa-edit"></i>
<% end %>
<%= link_to catalog_membership, method: :delete, data: { confirm: '¿Seguro que desea eliminar?' }, class: "btn-white btn btn-xs" do %>
<i class="fa fa-times"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
<tfoot>
</tfoot>
</table>
<% else %>
<br>
<div class="text-center"> No existen membresías registradas </div>
<% end %>
<div class="text-center"><%= paginate catalog_memberships %></div>
我认为你需要关闭
<div id="filterrific_results">
我在 rails 4 中遇到了这个问题,我有一个使用 gem kaminari 分页的列表,并使用 gem filterrific 按名称进行筛选。当页面刚加载时一切正常,但在我移动到另一个页面后过滤器不起作用,除非我在输入中单击 enter。
这是我的代码:
index.html.erb
<%= link_to 'Agregar Membresía', new_catalog_membership_path, class:"btn btn-primary btn-sm", style:"margin-bottom: 10px" %>
<div>
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Membresías Registradas</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="ibox-content">
<%= form_for_filterrific @filterrific do |f| %>
<%= f.text_field(:search_query, id:"filterrific_search_query", class: 'filterrific-periodically-observed form-control input-sm m-b-xs', name: "filterrific[search_query]",
placeholder: "Buscar membresía") %>
<% end %>
<%= render(
partial: 'catalog_memberships/list',
locals: { catalog_memberships: @catalog_memberships }
) %>
</div>
</div>
</div>
_list.html.erb
<div id="filterrific_results">
<% if catalog_memberships.count > 0 %>
<table class="footable table table-stripped">
<thead>
<tr>
<th width="50%">Nombre</th>
<th width="25%">Monto Total</th>
<th width="25%">Acciones</th>
</tr>
</thead>
<tbody>
<% catalog_memberships.each do |catalog_membership| %>
<tr>
<td><%= catalog_membership.nombre %></td>
<td><%= catalog_membership.monto_total %></td>
<td>
<%= link_to edit_catalog_membership_path(catalog_membership), class: "btn-white btn btn-xs" do %>
<i class="fa fa-edit"></i>
<% end %>
<%= link_to catalog_membership, method: :delete, data: { confirm: '¿Seguro que desea eliminar?' }, class: "btn-white btn btn-xs" do %>
<i class="fa fa-times"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
<tfoot>
</tfoot>
</table>
<% else %>
<br>
<div class="text-center"> No existen membresías registradas </div>
<% end %>
<div class="text-center"><%= paginate catalog_memberships %></div>
我认为你需要关闭
<div id="filterrific_results">