2014-01-14 35 views
1

嗨,我使用表分揀自舉3 該插件的URL是 http://mottie.github.io/tablesorter/docs/表格分頁器頁面不能在頁面中使用多個表格。只有第1次10項可見

一切正常時,只有一個頁表。我已經做了之後 http://mottie.github.io/tablesorter/docs/example-widget-bootstrap-theme.html

像$(「表」),它讀取。的tablesorter({......})

但是,當有多個表在同一頁中,尋呼機不工作。箭頭被禁用,奇怪只有前10個項目可見。似乎tablesorter激活作爲排序工作,但分頁不起作用。

沒有箭頭工作。當我只保留一張桌子。它工作正常。 我嘗試了一切,但失敗了。任何人都可以幫忙

謝謝!

+0

請提供[JSFiddle](http://jsfiddle.net),顯示您的問題的示例。 –

回答

2

我想我回答你的問題在tablesorter issue。基本上,確保每個尋呼機具有指定表的唯一名稱。

<table class="table1">...<table> 
<div class="pager1">...</div> 

<table class="table2">...<table> 
<div class="pager2">...</div> 

然後初始化每個表單獨

$(".table1").tablesorter().tablesorterPager({ container: '.pager1' }); 
$(".table2").tablesorter().tablesorterPager({ container: '.pager2' }); 
0

我在同一個問題擊中過,因爲我總是擔心被儘可能的通用,我做了這個簡單的代碼,讓ID來表,它們在代碼中出現時編號,並將特定的尋呼機應用於每個表。

JS

$(".tablesorter table").each(function(pageTableCount){ 

    // Check if pageTableCount was initialized, and add 1 to its value 
    pageTableCount !==null ? pageTableCount++ : 1; 

    // Get the table and add ID with counter 
    table = $(this); 
    table.attr("id","table-sorter-"+pageTableCount); 

    // Does the same with the pager 
    pager = table.parent().find(".tablesorter-pager"); 
    pager.attr("id","table-sorter-pager-"+pageTableCount); 

    // Initiate the tablesorter 
    table.tablesorter() 
    .tablesorterPager({ 
     container: "#table-sorter-pager-"+pageTableCount 
    }); 

    }); 

HTML(BS + FontAwesome)

 <div class="table-responsive tablesorter"> 
      <table class="table"> 
      <thead> 
       <tr> 
       ... 
       </tr> 
      </thead> 
      <tbody> 

       <tr> 
       ... 
       </tr> 

      </tbody> 
      </table> 
      <div class="tablesorter-pager"> 
      <a href="#" class="first btn btn-default btn-sm btn-icon"><i class="fa fa-angle-double-left"></i></a> 
      <a href="#" class="prev btn btn-default btn-sm btn-icon"><i class="fa fa-angle-left"></i></a> 
      <span class="pagedisplay"></span> 
      <a href="#" class="next btn btn-default btn-sm btn-icon"><i class="fa fa-angle-right"></i></a> 
      <a href="#" class="last btn btn-default btn-sm btn-icon"><i class="fa fa-angle-double-right"></i></a> 
      </div><!-- tablesorter-pager --> 
     </div><!-- .table-responsive --> 

希望它能幫助。

0

您可以在一個使用表分揀機的多個表。請參考這個。 http://www.pearlbells.co.uk/table-pagination/

+0

請注意,[只有鏈接的答案](http://meta.stackoverflow.com/tags/link-only-answers/info)不鼓勵,所以答案應該是搜索解決方案的終點(vs.而另一個引用的中途停留時間往往會隨着時間推移而過時)。請考慮在此添加獨立的摘要,並將鏈接保留爲參考。 – kleopatra