Ajax Will_Paginate with jQuery
Recently for work I had to use ajax to reload a paginated list. I quickly found this post on using will_paginate with ajax, but the official solution uses prototype instead of jQuery, so I spent some time figuring out how to do it with jQuery in a DRY way. Here’s what I came up with (code hosted in a github gist):
When you first load up items/index, the html responder just loads the index view via the _items partial. If you click any of the ajax_will_paginate buttons, the link href will get sent via ajax, the index action will return just the _items partial, and ajax_will_paginate will update the contents of the my_items_list div. If javascript is disabled then clicking on the will_paginate links will work normally.
this is why i love you, daniel.
Does not work for me get error:
“undefined method `total_pages”
rails 3 + will_paginate (3.0.pre2) + jquery
cheers, philipp
I don’t really know what your problem could be, but I’ve never done anything in Rails 3 before. I would suspect that as being the general problem. Sorry it doesn’t work.
Found this Railscast:
http://railscasts.com/episodes/174-pagination-with-ajax
@Daniel
Thank you very much.
I found a way to get it work.
Kind regards
Hi philipp,
I tried the ajax pagination as said by Daniel. But me to got the same error undefined method `total_pages’. So can u suggest me the solution.
thanks in advance
Kiruthiga Arunachalam