From the course: Learning Backbone.js

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Solution: Create a template

Solution: Create a template - Backbone.js Tutorial

From the course: Learning Backbone.js

Start my 1-month free trial

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…

Contents