Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rails style routing for jQuery.
branch: master

This branch is even with eastridge:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
docs
examples
lib
test
README.markdown
Rakefile
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);
Something went wrong with that request. Please try again.