views:

66

answers:

4

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 (for 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.

+1  A: 

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

Jordan
Yes. I've tried this, but although it works, when I click on any of the pages of the plugin, using firebug I've seen that it's executing many ajax calls...do you know why may this happen?
Brian Roisentul
No I don't. I'd have to see your implementation and the calls it's making.
Jordan
+1  A: 

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

rspeicher
Could you please tell me how to use it? I've added the three files but it's still now working. I guess I must be missing something.
Brian Roisentul
Well... yeah, those are just examples. Of course they're not going to work if you just drop them in.
rspeicher
Could you explain me how that works, please?
Brian Roisentul
+1  A: 

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.

Tim
+1  A: 

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

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