1

这是我现在的路由器:

CRM.Router = Marionette.AppRouter.extend({
    appRoutes: {
        "customers"         : "listCustomers",
        "customers/:id"     : "showCustomer",
        "customers/add"     : "newCustomer",
        "customer/search"   : "showCustomerSearch"
    }
});
CRM.navigate = function (route, options) {
    options || (options = {});
    Backbone.history.navigate(route, options);
}
CRM.getCurrentRoute = function () {
    return Backbone.history.fragment;
}
CRM.addInitializer(function () {
    var router = new CRMApp.Router({
        controller: API
    });
});
CRM.on("initialize:after", function () {
    if (Backbone.history) {
        Backbone.history.start({ pushState: true, root: '/app/' });
        if (this.getCurrentRoute() === "") {
            CRM.trigger("customers:list");
        }
    }
});

Going tocustomers工作得很好,但Going tocustomers/add似乎想要加载customers内容。不知道为什么。我应该以不同的方式处理customers以允许小节吗?

建议?

4

1 回答 1

0

刚刚重新排序路线,它的工作原理:

CRM.Router = Marionette.AppRouter.extend({
    appRoutes: {
        "customers"         : "listCustomers",
        "customers/add"     : "newCustomer",
        "customers/:id"     : "showCustomer",
        "customer/search"   : "showCustomerSearch"
    }
});
于 2013-10-17T20:46:18.490 回答