I have a View which is composed of another view (sub view) which has add/edit functionality , now I want to use routing so that on clicking Add a new View (Add) is displayed replacing the original view, I have tried using child router but it is not working ...
Shell is my first view where I setup my router to take the user to Pulse view --
function boot() {
datacontext.getstartupdata().then(function () {
log('Helium SPA Loaded!', null, true);
router.on('router:route:not-found', function (fragment) {
logError('No Route Found', fragment, true);
});
return router.makeRelative({ moduleId: 'viewmodels' }) // router will look here for viewmodels by convention
.map([{ route: '', moduleId: 'pulse', title: 'Pulse', nav: true }]) // Map the routes
.buildNavigationModel() // Finds all nav routes and readies them
.activate('');
// Activate the router
});
}
Now in the pulse view HTML I have --
<article class="tasks-container" >
<!--ko router: { transition:'entrance' }--><!--/ko-->
</article>
and in the View Model (.js) file I have --
var childRouter = router.createChildRouter()
.makeRelative({
moduleId: 'viewmodels'
}).map([
{ route: '', moduleId: 'tasklist', title: 'Task List', nav: true },
{ route: 'tasklist', moduleId: 'tasklist', title: 'Task List', nav: true },
{ route: 'newTask', moduleId: 'newTask', title: 'New Task', nav: true},
{ route: 'newTask/:taskId', moduleId: 'newTask', title: 'Edit Task', nav: true }
]).buildNavigationModel();
var pulse = {
activate: activate,
compositionComplete: compositionComplete,
router: childRouter
};
return pulse;
so the Tasklist is bound in the Pulse view as per the KO binding in the HTML but now in the Tasklist view model when I try to navigate to New Task view --
var showNewTask = function() {
var url = '#newTask/';
router.navigate(url, { trigger: true, replace: false });
};
I get a 'Route Not Found' error, please help