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

Creating and configuring templates - Backbone.js Tutorial

From the course: Learning Backbone.js

Start my 1-month free trial

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…

Contents