I created a little utility class that combines window.location.hash
monitoring (and uses the onhashchange event when available) with query
string <---> object conversion functions, providing a handy interface
for creating and retrieving application states.

As soon as you instantiate the class, you can attach a
"navigationChanged" event to it, and whenever the hash changes, it
will be converted to an object and sent out with the event. The class
also provides utility functions for modifying the hash with key/value
pairs. Combining these two pieces of functionality allows the class to
sit between your UI elements and the actual application logic.

Because the class relates unrelated functionality, it's not really
written in the MooTools style -- for example, I don't extend the
hashchange event, since the event's data isn't the hash string, but
rather an object decoded from it, so I have to do everything in the
class.

This is the first class I've ever "released" -- I would love someone
smart chiming in with suggestions on ways to improve it.

You can find information about it here:
http://www.jaycarlson.net/blog/2010/06/22/a-mootools-powered-ajax-navigation-class/

Or just download the class at 
http://www.smmirror.com/js/debug/classes/navigation.js

(docs are in the comments section at the top of the file).

I'm eager to hear what you guys think!

Reply via email to