Rails endless pagination should remember previous position when back from other page

990 views Asked by At

I'm using Kamanari gem and jQuery infinite scroll for endless pagination. Everything works perfectly but when I visit other page and back to posts list page then the pagination starts from first page. Instead of starting pagination from first page it should remember the previous post location.
I tried JavaScript History API: pushState and replaceState to update the URL according to the scroll position and navigate away from that page and click on browsers back button. It take me to previous scroll positions by scrolling and loading the contains till I get to previous scroll position. But this is taking too much of time by scrolling and loading the contains. What I need is to be instantly back to the previous scroll position when I click browser back button just like in mobile Facebook, Twitter and G+.
What will be the best solution? How can I achieve this task?
Thanks in advance.

0

There are 0 answers