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.
Solution: Create a template - Backbone.js Tutorial
From the course: Learning Backbone.js
Solution: Create a template
[MUSIC] Let's take a look and see how I approach the challenge. I created a script tag with an ID name of stateFlowerElement and made sure that it had the proper casing I discussed in the last movie. We can see this code on line 26. I also made sure that it had a type that was not text/JavaScript, and instead gave it a type of text/template. The type definitely had to be there, but as long as it was set to anything other than text/JavaScript, the value could be whatever you wanted it to be. Now, as a reminder, content wrapped in a template tag can't be rendered in HTML on its own. It needs Backbone to load it into a pre-determined webpage element. So, based on how my code was working behind the scenes, that was why we needed to create an element called stateFlowers. I created a div tag in this case and gave it an id name of stateFlowers. And again, I made sure to create it using the proper casing. We can see this code on line 19. I also placed it relatively close to the top of the…
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)
-
-