简体   繁体   中英

Rails 4, Kaminari and Filterrific issue after first page

I have this issue in rails 4, I have a list paginated using the gem kaminari, with a filter by name using the gem filterrific. When the page just loaded everything works fine, but after I move to another page the filter doesn't work unless I click enter in the input.

Here is my code:

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">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM