From the course: Learning Backbone.js

Unlock the full course today

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

Watching for model changes

Watching for model changes - Backbone.js Tutorial

From the course: Learning Backbone.js

Start my 1-month free trial

Watching for model changes

Most backbone components have an internal method called Initialize and its purpose is to execute code as soon as a new instance of a component has been created. Now, Initialize is commonly used to watch for any changes applied to models but, I don't really need that for the web app I'm creating. Also if the model changes, it's usually the result of some information being passed from a web form. And that information needs to be saved somehow, using either a database or something known as a wrestle-pattern. Those are several related technologies, so I won't be discussing them in this course. Now I'm not going to use Initialize in my final project. However, it's still a good idea to see how this watching for model changes process works as it's one of the best ways to understand Initialize. So in this video, we're going to use this function to watch and listen for model changes. Once we create a backbone model instance, we have access to all of its attributes and can use them in our web…

Contents