第一页后的Rails 4,Kaminari和Filterrific问题

时间:2016-04-02 16:17:38

标签: ruby-on-rails kaminari filterrific

我在rails 4中有这个问题,我有一个使用gem kaminari分页的列表,使用gem filterrific按名称过滤。当刚加载的页面一切正常时,但在我移动到另一个页面之后,除非我单击输入输入,否则过滤器不起作用。

这是我的代码:

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>

1 个答案:

答案 0 :(得分:0)

我认为你需要关闭

<div id="filterrific_results">