I recently had to implement some ajax pagination for a site. After googling for a while I found a solution, but I couldn’t customize the pagination url’s or I had to specify the paginator to use (will paginate’s default or mine for ajax), so I came up with this solution which fulfils all my needs.
First create the following class in your app/helpers.
Then you have to tell will_paginate which link_renderer to use, I do this in a rails initializer.
So with this solution, you can work like you would normally with will_paginate, but if you need to do an ajax link, then you’ll have to pass the options in the remote hash, something like this:
That’s it enjoy. You can keep passing the same options you would normally do to will_paginate to customize the behaviour.