I have single page application. All data is retrieved by ajax and rendered on client. I have the next workflow:
- User opens list of items. List has infinity scroll
- User scrolls and clicks on item
- System makes ajax request, generates new html and replaces previous content
- User clicks on browser’s back button
- System changes url (historyjs) and router loads items and renders list. But the position of scroll is LOST ! So user needs to scroll to go to the previous position on the list.
How to preserve this position during back / next actions and implement generic solution for all project ?
Here is my solution (coffeescript):