Rails style routing for jQuery.
JavaScript
Permalink
Failed to load latest commit information.
docs
examples added examples Jan 5, 2011
lib
test added direct routing to View via implicit set method Feb 8, 2011
README.markdown
Rakefile fixed docs Jan 12, 2011
jquery.routes.js
jquery.routes.min.js

README.markdown

jQuery Routes

Download: Development | Production (6KB)
See Also: jQuery View

Rails style routing for jQuery. Enables back button support, deep linking and allows methods to be called by normal links in your application without adding an event handler. Methods that have been specified in your routes will automatically set the URL of the page when called.

$.routes({
  "/": "PageView#home",
  "/article/:id": "ArticlesView#article",
  "/about/(:page_name)": function(params){}
});

Clicking: <a href="#/article/5"></a>
Will call: ArticlesView.instance().article({id:5})

Calling: ArticlesView.instance().article({id:6})
Will set URL: "#/article/6"

jQuery Routes depends on the jQuery Address plugin which is included in the production build.

Alternatively, you can use jQuery Routes to emulate the hashchange event

$.routes(function(new_hash){
  //do stuff
});

To unregister the handler above:

$.routes(false);