jQuery Address

Posted: 2013-01-14 07:50:00
Simple example of jQuery.address in use. As you click the top "black" menu area the pages will load via Ajax (and title) notice also the URL. Then if you click back it forces a reload. There is very little code needed to make this work. Other than the ajax callback I run this on page load (eg pressing back on the browser button)
 //Jquery Address clicking back
 $.address.externalChange(function(){
    if($.address.value() !== '/') {
     updateMe($.address.value());
    }
 });
The externalChange reacts to the page load or back button and runs this function(s). In this case I run a function and pass the path to it. All that function does is run jQuery.ajax based on the path and lastly

$.address.value(path);

and this updates the path. That is it. One other thing is I set the state to

$.address.state('/');

This made it possible to remove the # from the url.

Tags:

JavaScript