Hi All,
I have a page where I need to load child routes via a child composition rather than via the original parent composition. However when I do this it breaks the back button. I think the back button still maintains the child router, which it shouldn't. Here's a contrived example:
// shell.js
define(['router'], function Shell(router) {
return {
router: router,
activate: function() {
return router.map([
{ route: ['', 'products'], moduleId: 'product' },
{ route: 'products/*details', moduleId: 'product', hash: '#products' }
]).mapUnknownRoutes('product', 'products')
.activate();
}
};
});
// shell.html
<div data-bind="router: { transition:'entrance', cacheViews:false }"></div>
// product.js
define(['router'], function Product(router) {
var childRouter = router.createChildRouter().makeRelative({
fromParent: true
}).map([
{ route: ':id', moduleId: 'productDetail', title: 'Detail', type: 'intro', nav: false }
]);
return {
router: childRouter,
activate: function() {}
};
});
// product.html
<div data-bind="router: { transition:'entrance', cacheViews:false }"></div>
// productDetail.js
define([], function ProductDetail() {
return {
activate: function(id) {
// request some server data using the id
}
};
});
When I visit the child route (#product/123) and then click the back button, I get a hash something like this:
#123
When it should be
#product
Any ideas what might be happening?