1

So I've created a nicely working child router with durandal, and I'm trying to add it's routes to my main navigation in a dropdown. I am using bootstrap just to make that clear.

I have no issue with the general syntax of getting this to work. The problem is how to correctly give my main nav access to the child routes.

So to break down the details briefly:

App/
---ViewModels/
------Config/
---------index.js
------nav.js
---Views/
------Config/
---------index.html
------nav.html

(hope that folder structure is clear)

The nav view model has a reference to the main router, and I bind the navigationModel property correctly to get the root menu items. I tried including config/index.js in the viewmodel, and creating a property childRouter, and then binding the dropdown elements to childrouter.navigationModel. This does create the right items, but the hashs for each route a garbage. Instead of being config/x or config/y, they just become x and y.

I don't understand that as the child router is still being built from the main router, and includes the makerelative function like so:

define(['services/router'],
    function (router) {
        var childRouter = router.createChildRouter()
            .makeRelative({
                moduleId: 'viewmodels/config',
                fromParent: true
            }).map([
                { route: 'x', moduleId: 'x', title: 'X', nav: true },
                { route: 'x/:accountId', moduleId: 'xItem', title: 'X', nav: false },
                { route: 'y', moduleId: 'y', title: 'Y', nav: true }
            ]).buildNavigationModel();

I assumed that it would generate hashes from that relative point, but it seems to be doing it from the root.

Any ideas?

Adam
  • 1,011
  • 1
  • 10
  • 25
  • Check this out - http://stackoverflow.com/questions/17665615/how-to-use-dropdowns-for-durandal-navigation?rq=1 - I think it might help you find the answer you are looking for. If not let me know and I can answer a bit further - Actually after reading I see you are trying to accomplish something else, give me a second to create an answer – PW Kad Sep 16 '13 at 00:01
  • Did you find a solution yet? – Remco Ros Oct 22 '13 at 15:18

0 Answers0