Domanda

I have a master/detail situation. I'd like to employ a child router so that I can (a) make full use of the history module and (b) trigger the entrance transition on only the child. Here's my setup:

Shell.js

// configure the shell router
router.map([{ 
    ...
},{ 
    route: 'users*edit', 
    title: 'User List', 
    moduleId: 'viewmodels/users' 
}]).activate();

Users.js

this.router = router
    .createChildRouter()
    .makeRelative({ fromParent: true })
    .map({ route: ':id', moduleId: 'viewmodels/edit' })

When I navigate to #/users/5 it works brilliantly. However, when I navigate to #/users, as expected, it fires a route not found, cancels navigation, and returns me to #/users/5. How should I configure this to disable the child view when the route is not found? Ideally, I'd like to have something like this:

Users.js

this.router = router
    .createChildRouter()
    .makeRelative({ fromParent: true })
    .map([ 
        { route: ':id', moduleId: 'viewmodels/edit' },
        { route: '', moduleId: null }
])

where the router will successfully navigate to the '' route but the null parameter will instruct it to simply empty the router binding handler.

È stato utile?

Soluzione

This is not currently a feature of Durandal. I have added support for this kind of thing in a pull request, which you can find here, in case you would like to add support for null routes to your app.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top