2013-03-17 58 views
0

我试图使用带有参数,由于某种原因骨干线路骨干路由器,我似乎无法使下面的代码工作:当我尝试与参数不工作

var App = new Backbone.Marionette.Application(); 

App.Router = Backbone.Router.extend({ 
    routes: { 
     "export": "export", 
     "show": "show/:id", // This just won't work 
     "providers": "providers" 
    }, 

    export: function() { 
     var exportView = new App.ExportView(); 
     exportView.render(); 
     $("#main").html(exportView.el); 
    }, 

    show: function(id) { 
     console.log('from here'); // This is not even firing 
     var show = this.collection.get(id); 
     showView.render(); 
     $("#main").html(showView.el); 
    }, 

    providers: function() { 
     var contentProvidersView = new App.ProvidersView(); 
     providersView.render(); 
     $("#main").html(providersView.el); 
    } 
}); 

App.addInitializer(function() { 
    var router = new App.Router(); 
}); 

什么也没有发生访问此:#show/2(其中2是展示ID)

非常感谢。

回答

4

它周围的其他方法:

routes: { 
    "show/:id": "show", 
}