Rails 3 - “更多”使用 Kaminari 进行 ajax 分页
I am trying to do a "Twitter like" pagination with a "More" button to load results with Kaminari.
I found this question here
But I can't figure out how to make it works and if it's a good approach.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的意思是您需要一个“更多”按钮吗?创建一个这样的助手怎么样?
如果您觉得有用,我准备将这种辅助方法包含到 gem 中,所以请让我知道您的想法。谢谢!
Do you mean you need a "more" button? How about creating a helper like this?
I'm ready to include this kind of helper methods to the gem if you find it useful, so please let me know what you think. Thanks!
请记住,
link_to_next_page(@items, :remote => true)
开箱后无法正常工作。由于在 Ajax 请求后无法确定当前页面,因此在获取新项目后需要替换链接。使用 unobtrusive javascript,这看起来像这样:如果这没有意义,请查看 Railscasts 上的不引人注目的 Javascript 截屏视频。
Keep in mind that
link_to_next_page(@items, :remote => true)
won't work correctly out of the box. Since it has no way to determine the current page after an Ajax request, the link needs to be replaced after new items are fetched. Using unobtrusive javascript, this would something look like this:If this doesn't make sense, take a look at the Unobtrusive Javascript screencast at Railscasts.