簡體   English   中英

ajax調用后,sorter插件不起作用(jquery tablesorter)

[英]sorter plugin does not work after ajax call ( jquery tablesorter )

我正在使用Ruby on Rails,並使用ajax_will_paginate呈現頁面。 它工作正常,但是我在HTML頁面中使用了JavaScript表排序。 當我單擊下一頁時, ajax_will_paginate將刪除表排序功能。

這是我的_cantacts.html.erb

<table class="tablesorter">

         <thead>
          <tr>
            <th>Name</th>
            <th>Office</th>
            <th>Fax</th>
            <th>Cell</th>
            <th>Email</th>
            <th>Position</th>
            <th>Mainconact</th>
            <th></th>
            <th>Actions</th>
          </tr>
        </thead>

        <tbody>
          <% @contacts.each do |contact| %>
            <tr>
              <td><%= contact.Name.capitalize %></td>
              <td><%= contact.Office %></td>
              <td><%= contact.Fax %></td>
              <td><%= contact.Cell %></td>
              <td><%= contact.Email %></td>
              <td><%= contact.Position %></td>
              <td><%= contact.MainContact %></td>
              <td><%= link_to 'Show', edit_contact_path(contact) %></td>
              <!--<td><%= link_to 'Edit', edit_contact_path(contact) %></td>-->
              <td><%= link_to 'X', contact, :class=>'rmv-fld', method: :delete, data: { confirm: 'Are you sure?' } %></td>
            </tr>
          <% end %>
        </tbody>
      </table>

index.js.erb是:

$('.sort_paginate_ajax').html("<%= escape_javascript(render("contacts"))%>")

在將部分內容呈現到html元素之后,通過調用tablesorter插件函數來更新DOM。

index.js.erb的。

$('.sort_paginate_ajax').html("<%= escape_javascript(render("contacts"))%>")
$(".tablesorter").tablesorter(); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM