Compatibility with marionette 4
Closed this issue · 2 comments
Deleted user commented
Hello.
I'm trying to use this routing system with marionette 4.0.0 but seems it doesn't render the view you pass to the router.
import {Application, View, Region} from 'backbone.marionette';
import {createRouter, middleware} from 'marionette.routing';
import _ from "underscore";
const MyApp = Application.extend({
region: '#app',
initialize() {
console.log('start app');
},
});
const app = new MyApp();
const aView = View.extend({
template: _.template('<h1>testing</h1>'),
});
document.addEventListener("DOMContentLoaded", function () {
app.start();
let router = createRouter({log: true, logError: true});
router.map(function (route) {
route('app', {path: '/', abstract: true}, function () {
route('dashboard', {path: '', viewClass: aView})
})
});
router.rootRegion = new Region({el: '#app'});
router.use(middleware);
router.listen();
});
The router works and is logging info in the console but the view is not rendered.
Where am i wrong ?
blikblum commented
You need to define a routeClass for 'app' route:
import {createRouter, middleware, Route} from 'marionette.routing';
route('app', {path: '/', abstract: true, routeClass: Route}, function () {
route('dashboard', {path: '', viewClass: aView})
})
blikblum commented
Version 0.9.1 has a better error logging