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.

Adding properties to the model view

Adding properties to the model view - Backbone.js Tutorial

From the course: Learning Backbone.js

Start my 1-month free trial

Adding properties to the model view

Okay, let's get started by building the view for a single model instance. So, I'm in singleFlowerView.js. This is where the single view code will be going, and I'm going to go over to snippets.txt. And I'm going to highlight and copy lines 10 through 19 and go back to singleFlowerView and paste this code in and save it. So, as I've done for models and collections, I'm name spacing my code on line two. On line five, I'm creating a name space variable called app.singleFlowerView and using it to create a brand new view with Backbone.View.extend. Let's gradually add some more code. So, back to snippets.txt. And highlight and copy lines 27 through 28 and go back to singleFlowerView.js. And I'm going to paste this code inside of my view object. Get rid of this extra white space and save it. So, I'm starting to configure this view with properties that are available to all views. tagName defines which HTML tag my single model data should be placed in. I've said in the last movie, this is…

Contents