Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Ajax based will_paginate
3 Posts
Ajax based will_paginate

It's very easy, and there are many blog posts showing how. "Follow these instructions":http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links

Abdul,

I find the best way to think about using RJS is to break up your web page into distinct sections. Let's assume, for the purpose of this answer, that you have a Wibble which has_many Chunklets. Your Wibbles#show page has one section that displays a list of associated Chunklets, and that's what you want to update via RJS.

You'll want to display the chunklets section as part of the full show page (the HTML request), as well as send it as your RJS update. So, pull your chunklet list view code into a partial; let's say chunklets/_list.html.erb. Now, your widgets/show.html.erb view will simply render that partial:

page.replace_html('.chunklets', :partial => 'chunklets/list', :locals => { :chunklets => @chunklets }
This RJS will replace everything inside the div with class 'chunklets' with the contents of your partial. As long as your pagination links are inside this div they'll be replaced each time you change pages, so they'll always be up to date. Since you're rendering the same partial for both the HTML response and the RJS response you know your page will remain consistent. Does that help?

Hi all, Can anyone please help me on how to develop AJAX based(JQUERY+RJS) pagination with will_paginate(mislav)?I got some source but it does not work properly.Please help me with proper example,I want such pagination so that I may use pagination with AJAX or without AJAX in my App.Please please help me.

Thanks

Person
Forum Rating: 100
Sign In To Rate Post
3 Posts
Login to add your message