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.
Creating and configuring templates - Backbone.js Tutorial
From the course: Learning Backbone.js
Creating and configuring templates
So now it's time to create a template. So it's back to snippets.txt, and I'm going to highlight and copy lines 36 to 43. And now I'm going to go to my index.html file and paste this code directly below the script tags at the bottom. Do a little white space so we can see what we're doing. Save that. So I've enclosed all my code inside of a script tag starting on line 34 and it has two attributes, ID and type. ID will act a shook for the template settings I'm about to define in my view object. It will tell the view how to structure my model data. Now, type needs to be here but it absolutely cannot be text forward slash JavaScript. Otherwise, the browser will try to execute it as JavaScript, which I don't want because this will break my code all together. Its convention to finite as text forward slash template, so that's what I've done here. Now inside this tag, I've defined HTML structure for my model data. So, I've created an anchor tag right here on line 35, and if I look at its href…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Understanding views4m 13s
-
(Locked)
Adding properties to the model view2m
-
(Locked)
Creating and configuring templates7m 1s
-
(Locked)
Creating a collection view5m 43s
-
(Locked)
Loading model data on a webpage4m 38s
-
(Locked)
Challenge: Create a template2m 45s
-
(Locked)
Solution: Create a template2m 42s
-
(Locked)
-
-