2016-01-21 52 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寻呼但不能同时。希望这可以帮助。