2013-03-17 62 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", 
}