1
這裏是我當前路由器:在Backbone Marionette路由器中允許「子目錄」的正確方法是什麼?
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
允許子部分?
對此提出建議?