Created
May 6, 2010 19:50
-
-
Save rgrove/392619 to your computer and use it in GitHub Desktop.
Using custom hash values with YUI 3.2.0 (dev) History
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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