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

1 回答 1

4

反过来说:

routes: {
  "show/:id": "show",
}
于 2013-03-17T17:35:37.013 回答