Question

Here is my current router:

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 to customers works wonderfully, but going to customers/add seems to want to load the customers content. Not sure why. Is there a different way I should be handling customers to allow for subsections?

Suggestions?

Was it helpful?

Solution

Just reordered the routes and it worked:

CRM.Router = Marionette.AppRouter.extend({
    appRoutes: {
        "customers"         : "listCustomers",
        "customers/add"     : "newCustomer",
        "customers/:id"     : "showCustomer",
        "customer/search"   : "showCustomerSearch"
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top