We've already got a basic version of this from the template. However, we need to adjust the script tags at the bottom. After the tag for backbone.js
, but before the tag for app.js
, you'll want to add the following line:
<script>var USER = <%- user %>;</script>
This is the user
object that is the user that is currently logged in. We'll need to be able to work with some of its properties inside our application components, which is why we need to load it before the app.js
file.
Speaking of the app.js
file, that's our next stop. This time, we're going to begin with a router:
var AppRouter = Backbone.Router.extend({ initialize: function (options) { this.main = options.main; this.navView = new NavView(); }, routes: { '': 'index' }, index: function () { this.main.html(this.navView.render().el); } });
This is very similar to the router from our previous application. Any options—such as DOM elements, models, or collections...