Router provides methods for routing client-side pages, and connecting them to actions and events based on hashchange event, written in MooTools.
var App = Router.implement({
// routes definition
routes: {
'' : 'index',
'#!help' : 'help',
'#!test1/:query/:id?' : 'test1',
'#!test2/:query/*' : 'test2',
},
// router init
init: function(){
console.log('init')
},
// before route method
before: function(){
console.log('before')
},
// routes methods
index: function(){
console.log('index')
},
help: function(){
console.log('help')
console.log(this.route,this.req,this.param,this.query)
},
test1: function(){
console.log('test1')
console.log(this.route,this.req,this.param,this.query)
},
test2: function(){
console.log('test2')
console.log(this.route,this.req,this.param,this.query)
},
// after route method
after: function(){
console.log('after')
},
// no route match
notfound: function(){
alert('notfound')
window.app.navigate('');
}
});
window.app = new App();
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus