durandaldurandal-2.0durandal-navigation

Splat Route Not Found (DurandalJS)


I have settings splat route configured in shell.js:

router.map([
   { route: 'settings*child', moduleId: 'views/settings/main', nav: true }
]).buildNavigationModel();

And inside the views/settings/main.js file i've created child router:

var childRouter = router.createChildRouter().makeRelative({
    moduleId: 'views/settings',
    fromParent: true
}).map([
   { route: 'users',     moduleId: 'child/users/list', nav: true },
   { route: 'users/:id', moduleId: 'child/users/view', nav: false },
]).buildNavigationModel();

the folder structure is look like this:

/views  
-/settings  
--settings.js      
--settings.html  
--/child  
---/users  
----list.js  
----list.html  
----view.js  
----view.html

The problem i am faced is:

When i try to navigating to the settings (#settings) page from another parent route page it will show me an error message in console:

Route Not Found settings undefined

But the settings page is still showed up with all list of child router i've created.

Next, I try to navigate to the #settings/users and #settings/users/{id} and it work with no problem or error eventhough try it from another parent page.

I think the problem is splat route is always expected something would be in front of the hash by something like #settings/users and it WILL NOT accept #settings without the child ?

Or i've missed something on my implementation ?

Any help or suggestions would be appreciate!
Thank you!


Solution

  • I have a very similar setup, I create a route on the child router to represent the blank route like this:

    var childRouter = router.createChildRouter().makeRelative({
    moduleId: 'views/settings',
    fromParent: true
    }).map([
       { route: '', moduleId: 'main', nav: true },
       { route: 'users',     moduleId: 'child/users/list', nav: true },
       { route: 'users/:id', moduleId: 'child/users/view', nav: false },
    ]).buildNavigationModel();