开发者

Ajax pagination like Twitter

Is there any plugin/gem or an easy way for accomplish a pagination functionality like Twitter?

This means, showing a "More" button that shows more posts (f开发者_C百科or example) below once it's clicked, using Ajax.

If there's any easy way for modifying something from will_paginate plugin, that would be useful too.


I use this for easy pageless pagination. Seems to be a better solution w/o the more button.

http://github.com/jney/jquery.pageless


I've added a Twitter-like 'more' button on the app I'm currently working on. I used the exact method from http://railscasts.com/episodes/114-endless-page.

In this solution, more results are added to the bottom of the div once you scroll down to the bottom of the page resulting in an endless page. I changed the javascript so that it would send off the ajax request to add more results to the bottom of the div only when the 'load more' button is clicked.


The will_paginate project wiki has an entry on Ajax pagination. It's really quite straightforward.


I use Twitter-like pagination in one of my apps, so I'll just point you to that:

http://github.com/tsigo/jugglf/blob/master/lib/twitter_pagination.rb - Hooks into will_paginate to display the "More" button

http://github.com/tsigo/jugglf/blob/master/app/views/members/raids/index.html.haml - The view using the renderer from above

http://github.com/tsigo/jugglf/blob/master/app/views/members/raids/index.js.erb - The RJS view that appends the next set to the page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜