Join Kai Gittens for an in-depth discussion in this video Solution: Create a new model and watch when it changes, part of Learning Backbone.js.
…Let's take a look and see how I approach the challenge.…First, I created a collection called EuropeanFlower inside of js…> collections > allFlowers.js.…I made sure to assign my app.singleFlower model to this collection.…I then went over to my singleFlowerModel.js file and…added an initialized method starting on line 6.…I'm using this.on on line 8 to watch for any instance changes of any kind.…
When a change is applied, it should send a message to my browser console,…informing me of the change.…Now I chose to use the this.get method on line 9 to display…the instance name in my message, but this wasn't a requirement for this challenge.…It was more important that you actually get a message to display in the console.…The words you use to make up your message were not important.…Next, I created the tantalizingTulips and…fleurDeLis model instances inside of js > flowerApp.js.…
I made sure that their names were clear and related to my variable instance names,…but you could have used any instance names you wanted.…
- What is Backbone.js?
- Understanding how MVC libraries work
- Adding properties to a model
- Creating a collection of models
- Adding properties to a model view
- Loading model data on a web page
- Configuring routes
- Finding Backbone resources