【问题标题】:What is the proper way to allow for "subdirectories" in Backbone Marionette routers?在 Backbone Marionette 路由器中允许“子目录”的正确方法是什么?
【发布时间】:2013-10-26 12:25:13
【问题描述】:

这是我当前的路由器:

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");
        }
    }
});

转到customers 效果很好,但是转到customers/add 似乎要加载customers 内容。不知道为什么。我应该以不同的方式处理customers 以允许小节吗?

建议?

【问题讨论】:

    标签: backbone.js marionette backbone-routing


    【解决方案1】:

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

    CRM.Router = Marionette.AppRouter.extend({
        appRoutes: {
            "customers"         : "listCustomers",
            "customers/add"     : "newCustomer",
            "customers/:id"     : "showCustomer",
            "customer/search"   : "showCustomerSearch"
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多