Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created May 6, 2010 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgrove/392619 to your computer and use it in GitHub Desktop.
Save rgrove/392619 to your computer and use it in GitHub Desktop.
Using custom hash values with YUI 3.2.0 (dev) History
// Using custom hash values with YUI History. Requires the current dev version
// of History from YUI 3.2.0 in git:
// http://github.com/yui/yui3/blob/master/build/history/history.js
YUI().use('history', function (Y) {
// Listen for hash changes.
Y.on('hashchange', function (e) {
// The event facade (e) contains the following interesting properties:
// e.oldHash, e.oldUrl, e.newHash, e.newUrl
}, window);
// Change the hash to a custom value.
Y.History.setHash('mynewhash/foo/bar');
// Get the current hash value.
Y.History.getHash(); // => "mynewhash/foo/bar"
// Only caveat: since you're using a custom hash format, you'll have to parse it yourself.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment