From the course: Learning Backbone.js

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Setting up our files

Setting up our files - Backbone.js Tutorial

From the course: Learning Backbone.js

Start my 1-month free trial

Setting up our files

MVC's main goal is to make your code modular. It wants you to break your code out into separate units, or modules, while having them work together as a team inside your web app. Using modularized code is a recommended best practice in Backbone. So in this video, we're going to set up our apps file structure using modules. In JavaScript, modules are a way to refer to simple JavaScript files. In my Backbone app, modules will contain a specific block of code related to a particular Backbone component. So in other words, code related to a Backbone model would be placed in a JavaScript file with model code only. No view code or controller code is allowed, just model code and nothing else. This same principle would be used when creating view, collection, and router code. And as a reminder, Backbone event code is mixed in with the other components and won't be broken out into a separate file from my app. Now, modules make our code easier to understand and if we put it all in one long file…

Contents