Rails: will_paginate “显示下 10 个”按钮?
我在 Rails 3 应用程序上使用 will_paginate
gem。现在,它可以正确分页,并在列表底部显示所有页码,以及上一个和下一个按钮。
我希望分页表现得像 Facebook 新闻源,而不是显示页码。也就是说,如果我当前在页面上显示 10 个项目,并且用户单击“下一步”按钮,则页面应向下延伸,并总共显示 20 个项目。我正在寻找一种方法来修改 will_paginate
gem 或使用 AJAX 来完成此任务。
I'm using the will_paginate
gem on a rails 3 app. Right now, it paginates correctly, and shows all the page numbers at the bottom for the listing, as well as the previous and next buttons.
Instead of showing page numbers, I want the pagination to behave like the Facebook news feed. That is, if I am displaying 10 items on the page currently, and the user clicks the 'next' button, the page should extend downwards, and display 20 items overall. I'm looking for a way to modify the will_paginate
gem or use AJAX to accomplish this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请按照以下步骤在单击按钮时显示更多结果:
以下代码将删除页码,只显示下一个和上一个按钮:
您可以在此处找到更多分页样式
使用示例 AJAX 编辑:
1.创建一个将页码作为隐藏字段的表单
2.为“更多”添加一个跨度
3.用于绑定表单的点击和 AJAX 提交的 JavaScript 函数
4.相应地修改
appendData
。在这里查看有关 getJSON 的更多信息: http://api.jquery.com/jQuery.getJSON/Follow these for showing more results on click of button:
The following code will remove the page numbers and just show the next and prev buttons:
You can find more styles for pagination here
Edited with sample AJAX:
1.Create a form which has page number as hidden field
2.Add a span for "More"
3.Javascript functions for binding the clicks and AJAX submit of the form
4.Modify the
appendData
accordingly. Check here for more about getJSON: http://api.jquery.com/jQuery.getJSON/