Can someone explain why router.on("myTest", function(page) {}); does't work?

My Backbone.Routeris as follows:

var MyRouter = Backbone.Router.extend({
    initialize: function(){
        Backbone.history.start({ pushState:true, root:"/subdir/" });
    },
    routes: {
        '' : 'start',
        'base' : 'myTest',
        'base/:name': 'myTest',
        'base/:name/:skill': 'myTest',
        '*default': 'defaultRoute'
    },
    start: function(){
        alert('Chapter 5 route invoked');
    },
    defaultRoute: function(){
        alert('Router does not handle this route');
    },
    myTest: function(name,book){
        if(name !== undefined){
            if(book !== undefined){
                alert([name, 'is reading', book].join(' '));
            }else{
                alert('Saying hello to ' + name);
            }
        }else{
            alert('Saying hello!');
        }
    }
});

Related posts

Recent Viewed