jQuery Dynamic URL Demo

 

$.getPath()

$.getPath();
["github", "dynamic-url"]

This function return an Array with all the path's

 

$.pushPath( level, path, data )

$.pushPath(2, "newlevel", "This is the data element, its a String, but could be anything, any kind of object");
http://promatik.pt/github/dynamic-url/newlevel/

$.getPath();
["github", "dynamic-url", "newlevel"]

Did you notice the changes in the browser URL bar?

 

$.popPath( level, updateURL )

$.popPath(1);
http://promatik.pt/github/

$.getPath();
["github"]

All the paths after the first ( $.popPath(1) ), were removed...

 

$.onPopState( callback )

$.onPopState(function(e) {
alert(e.state);
});


//After running this, try to go back and forward in your browser!!!

This is where the funny beggins...
With this event listener you know when the user go back or forward in history, and you can associate a data object to each history entry!

 

$.pushVar( key, value, data, updateURL)

Lets add some vars to our URL

$.pushVar("grass", "green", "", false);
$.pushVar("sky", "blue", "", false);
$.pushVar("sun", "red", "You can also add some data here", true);

Did you notice that I set the data as an empty string in the first two pushVars?
Thats because I set the updateURL as false, so nothing will be updated, only at the third call...

 

$.popVar( key, updateURL )

As the sun is not red, is more like orange, lets remove that var ...

$.popVar("sun");
 

$.getVars( )

$.getVars();
{"grass" : "green", "sky" : "blue"}

$.getVars().grass;
"green"

 

$.getURL( )

alert( $.getURL() );
"http://promatik.pt/github/dynamic-url/?grass=green&sky=blue"

Easy isn't it?

jQuery Dynamic URL Download

It's highly recommended to download the plugin from GitHub, because it's always updated there!

Here is the link to GitHub: https://github.com/promatik/jQuery-Dynamic-URL

jQuery Dynamic URL Support

Support requests and general discussions about the Dynamic URL plugin can be posted in the official forum.

If your question is not directly related to the Dynamic URL plugin, you might have a better chance to get a reply by posting to Stack Overflow. Bugs and Feature requests can be reported using the issues tracker at GitHub.