Have you ever wondered why is there no remote option for will_paginate gem? It’s too complex and data dependent to handle all possible situations. I have made a workaround that can help you implement simple ajax pagination for your rails application. I will be replacing the whole yield part here, but you can customize it whatever way you like.
Step 1. Extract your required view into a partial so you have:
Step 2. Add a div surrounding your yield tag in your layout
Step 3. Create index.js.erb which will replace the contents of the div with paged table data.
Step 4. Bind the will_paginate link click to the rails remote call using coffeescript in
We also change the address in the navigation bar with PushState, because it can happen someone will press F5 or something and reload with a different
Update: As my coworker Oliver mentioned, i forgot to include responding to js in our controller for the index action