Skip to content

AdamPflug/routesjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Rails style routing for jQuery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published