How to fix the back button when user clicks a link from ajax-populated infinite scroll search results?
I have infinite-scrolling pagination on a search result page using ajax.
How can I ma开发者_开发知识库ke it so that when a user clicks a link off-site and returns via the back button, the results are scrolled into the ajax-loaded portion of the page where they left?
Google for jQuery ajax history plugins. There are many.
also look up jQuery haschange plugin: http://benalman.com/projects/jquery-hashchange-plugin/
basically you append / update (possibly increment) a '#result-set=1' to the page's URL. Then using the haschange plugin for eg. you can trigger your own code, move back or forward to how much of the results were shown by pagination etc. When a user clicks the back button and comes back to your page, the on load firing of haschange should work if you've wired up your pagination to work of the '#...' in the URL
Check out unspace's writeup of their Pageless implementation. They use a special div which gets moved along with scroll events, and also they use a temporary cookie to store the position.
精彩评论