2013-10-17 64 views
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允許子部分?

對此提出建議?

回答

0

只需重新排序的路線和它的工作:

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