【问题标题】:footable pagination not working on dynamic data Rails可脚分页不适用于动态数据 Rails
【发布时间】:2016-04-27 12:02:55
【问题描述】:

我正在尝试在我的 rails 应用程序中使用 footable。但我无法使用我的动态表数据实现分页。

这是我的代码

<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 条记录)。

如果有人发现这个问题,请帮助我,谢谢。

【问题讨论】:

    标签: javascript jquery ruby-on-rails pagination footable


    【解决方案1】:

    不确定您是否还有这个问题,但我偶然发现了这个问题,所以我想我会回答它。

    发生这种情况的原因是因为您在已经通过 Rails gem 分页的记录上调用 Footable 的 Paging Component,这表明您使用了

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

    因此,您的 Rails 应用程序只为 Footable 提供 10 条记录,然后尝试对这些记录进行分页。本质上,您是在“双重分页”一组数据。

    Footable V3 现在的语法是:

    通过 HTML 数据属性调用它

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

    通过 JS 调用

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

    请参阅Footable Paging Docs 了解更多信息。

    因此,基本上,选择 Rails PaginateFootable Paging,但不能同时选择两者。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-11
      • 2015-03-28
      • 1970-01-01
      • 2019-12-18
      • 2014-07-21
      • 1970-01-01
      • 1970-01-01
      • 2013-12-30
      相关资源
      最近更新 更多