3

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.

Ganesh Kunwar
  • 2,613
  • 1
  • 17
  • 36
  • 1
    Possible duplicate? http://stackoverflow.com/questions/3593843/how-to-fix-the-back-button-when-user-clicks-a-link-from-ajax-populated-infinite?rq=1 – rorykoehler Jun 23 '15 at 11:21
  • According to http://www.infinite-scroll.com/, "There is no permalink to a given state of the page". You also may [avoid using plugin](http://stackoverflow.com/questions/5059526/infinite-scroll-jquery-plugin) or use [another one, e.g.](https://github.com/artsy/scroll-frame) Read about [infinite scrolling that works](http://eviltrout.com/2013/02/16/infinite-scrolling-that-works.html) and [navigating back to previous location in infinitely scrolling page](http://ux.stackexchange.com/questions/72693/navigating-back-to-previous-location-in-infinitely-scrolling-page) – Nick Roz Jun 26 '15 at 11:11
  • Also, have a look [at this one](https://github.com/jeffstephens/infinitescroll). Actually, there are a lot of infinite scroll plug-ins, that work. – Nick Roz Jun 26 '15 at 11:16

0 Answers0