Routes containing changing parameter

11 views
Skip to first unread message

Leon Kladnitsky

unread,
Jan 25, 2015, 5:16:21 AM1/25/15
to backbone-...@googlegroups.com
Hi there

I need to set up application routing that depends on some parameter. The basic appRouter is working fine, but now I need the URLs to include some ID, and it should be inside the URL.

Here is the current (working) router:

module.exports = function() {
   
var cpRouter = new Marionette.AppRouter({
       
controller: new cpController({}),
        appRoutes: {
           
'cportal': 'cp_overview',
            'cportal/overview': 'cp_overview',
            'cportal/config': 'cp_conf',
            'cportal/config/:conf_type': 'cp_conf',
            'cportal/reports': 'cp_reports'
        }
   
});
    return cpRouter;
}

What I need is kind of : 

module.exports = function() {
   
var cpRouter = new Marionette.AppRouter({
       
controller: new cpController({}),
        appRoutes: {
           
'cportal/:id': 'cp_overview',
            'cportal/:id/overview': 'cp_overview',
            'cportal/:id/config': 'cp_conf',
            'cportal/:id/config/:conf_type': 'cp_conf',
            'cportal/:id/reports': 'cp_reports'
        }
   
});
    return cpRouter;
}

The problem is that second case is not working correctly: first line actually catches any URL, and changing the order of routes doesn't help.

I looked at whole bunch of examples, but none of them has this type of routing.

Any ideas?

Reply all
Reply to author
Forward
0 new messages