4
votes

I'm building a web app with jQuery & Rails. The web app loads pages with AJAX ... no page refresh.

When a user clicks on a link to load a new page via AJAX, i want to update the address bar. I also want to maintain the browser's back button support.

ideas?

2
I've tried "window.history.pushState" but that updates the URL but doesn't refresh the page, so the URL is right but the AJAX content driven stuff is stale... And I hear it won't be supported by IE9WozPoz

2 Answers

2
votes

I had the same demand on a project, this feature is called Deep link.

You just have to use a jQuery plugin called Address http://www.asual.com/jquery/address/, it makes everything easy. There is a wonderful documentation and examples on the site.

0
votes
  1. Link to e.g. #page1 or #page2; this will keep you on the same page
  2. Bind a function to these links that retrieves the window.location.hash
  3. Load the relevant data, depending on the retrieved hash info