In this article we will try to create start page creating
Note: Marionette.js is build on top of Backbone.js and as Backbone.js can’t work without jQuery, Underscore.js.
Lets write some code!
First of all you have to create an
html page with all needed dependancies.
Note: Scripts are loaded using cdn, instead of copying files locally.
#app is the main region where all content using Marionette.js will be rendered.
So we will extend
Marionette.Application class to create our own. We use for this inheritance principle.
Now, to show something in our region, we need to create a view.
Note: Here docs about views.
View is a jQuery selector to a script tag in our HTML body. For this example, we’re using Underscore template engine
To show View in main region lets use
showView method when application starts.
Final code of Application Class will be:
Lets put all code together in some file, call it
app.js and include it in
Note: All code is put in closure to prevent variables leaking into global scope.
Final working version you can find here.
Note: It uses ES2015 features.