Skip to content

Instantly share code, notes, and snippets.

@scott-w
Last active April 1, 2017 07:20
Show Gist options
  • Save scott-w/56d5ff0c7b3c3e0806d3f298883e3cae to your computer and use it in GitHub Desktop.
Save scott-w/56d5ff0c7b3c3e0806d3f298883e3cae to your computer and use it in GitHub Desktop.
Application Root
import {Application, View} from 'backbone.marionette';
import _ from 'underscore';
// If you use a navbar or panel
import {NavView} from './views/nav';
// Your home page
import {IndexView} from './views/index';
const RootView = View.extend({
template: _.template('<nav id="nav-hook"></nav><div id="body-hook"></div>'),
regions: {
nav: '#nav-hook',
main: '#body-hook'
},
onRender() {
this.showChildView('nav', new NavView());
this.showChildView('main', new IndexView());
}
});
const App = Application.extend({
region: '#root', // Your <div> identifier from before
onStart() {
this.showView(new RootView());
}
});
const app = new App();
app.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment