Lazy load url without having to append index
dottodot opened this issue · 4 comments
I'm wanting to lazy load a route but struggling with the parent child setup and getting the parent to work with having to append /index.
route('custom', {path: 'custom'}, function () {
route('custom.show', {path: ':slug'});
});
and my custom route is
import {Route} from 'marionette.routing';
import CustomIndexRoute from './index/route';
import CustomShowRoute from './show/route';
export default Route.extend({
childRoutes: {
'custom': CustomIndexRoute,
'custom.show': CustomShowRoute
}
});
index never loads doing it this way the only I've can find a way to make to work is by following the example that appends index.
Ok so I've worked out getting the parent route to load by doing
import {Route} from 'marionette.routing';
import CustomShowRoute from './show/route';
import LayoutView from './index/layout-view';
export default Route.extend({
activate(transition) {
},
childRoutes: {
'custom.show': CustomShowRoute
},
viewClass: LayoutView
});
but when I try add load the childRoute I get an error of
logger.js:17 Error: No outlet region in view
but when I try add load the childRoute I get an error of
logger.js:17 Error: No outlet region in view
In a route that has a view is necessary to define a Marionette Region named 'outlet' where the children will be rendered.
So in 'custom' route view add a region named 'outlet'
If 'custom' is supposed to not be parent of 'custom.show' but a sibling, i.e., rendered in the same region, is necessary to define then in same level.
Seems that you are trying to achieve a index route for a parent. Currently is necessary to redirect like as in https://github.com/blikblum/marionette-wires-revisited/blob/master/src/main.js#L62-L68
With most recent CherryTree will be possible to define an index route without the redirect and without add index in path
With latest version (0.5.3) is possible to define an index route with the same path as the parent route using abstract option. See https://github.com/blikblum/marionette-wires-revisited/blob/master/src/main.js#L49-L50 and https://github.com/blikblum/marionette-wires-revisited/blob/master/src/main.js#L56-L57
Is also possible to define a route being child of the other (regarding state) but both being rendered in the same region. This is accomplished by using outlet:false
option in the parent route. See https://github.com/blikblum/marionette-wires-revisited/blob/master/src/main.js#L52-L53.
Notice that colors.edit takes advantage of being child of colors.show by reusing the model through getContext.request
: https://github.com/blikblum/marionette-wires-revisited/blob/master/src/colors/edit/route.js#L10
Thanks for that upgrading to 0.5.3 resolved it along with the abstract option.