2016-01-21 53 views
1

我想在我的rails應用程序中使用footable,但我無法使用我的動態表數據實現分頁。footable分頁不能在動態數據上工作Rails

這裏是我的代碼

<table class="footable table table-stripped" data-page-size="10" data-filter=#filter> 
       <thead> 
       <tr> 
        <th>Organization Name</th> 
        <th>Type</th> 
       </tr> 
       </thead> 
       <tbody> 
       <%@organizations.each do |org|%> 
       <tr class="gradeX"> 
        <td><%=org.name%></td> 
        <td><%=org.type%></td> 
       </tr> 
       <%end%> 
       </tbody> 
       <tfoot> 
       <tr> 
        <td colspan="5"> 
         <ul class="pagination pull-right"> 
          <%=paginate @organizations%> 
         </ul> 
        </td> 
       </tr> 
       </tfoot> 
      </table> 
<script type="text/javascript"> 

$(function() { 
alert(); //testing 
$('.footable').footable(); 

}); 

</script> 

,但只顯示10條記錄,雖然它含有高達表45(最多顯示10條記錄,甚至改變數據頁大小)。

幫助我如果有人發現這個問題,Thaks提前。

回答

0

不知道你是否仍然有這個問題,但我偶然發現了這個問題,所以我想我會回答它。

這是發生的原因是因爲你叫上你已經通過Rails的寶石分頁記錄,通過您的使用

... 
<ul class="pagination pull-right"> 
    <%=paginate @organizations%> 
</ul> 
... 

所以Footable只被提供10條記錄顯示Footable的Paging Component你的Rails應用程序,然後嘗試分頁。本質上,你是「雙重分頁」一組數據。

Footable V3的語法是:

通過HTML數據調用它通過JS

屬性

<table class="footable table table-stripped" ... data-paging="true" data-paging-size="15" ... > 

調用它

$('.footable').footable({ "paging": { "enabled": true, "limit": 10 } }); 

參考Footable Paging Docs獲取更多信息。

所以基本上,選擇使用Rails的分頁Footable尋呼但不能同時。希望這可以幫助。