WozPoz
WozPoz

Reputation: 992

jQuery - Using Load & Updating the URL in the Address Bar while supporting the Back Button

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?

Upvotes: 4

Views: 1009

Answers (2)

Thiago Diniz
Thiago Diniz

Reputation: 3121

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.

Upvotes: 2

Alec
Alec

Reputation: 9078

  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

Upvotes: 0

Related Questions