Reputation: 1173
js app that is not displaying what it should.
Here's the app: http://jsfiddle.net/5sded/
It should be looping through the recipes, but instead it doesn't show anything. Here's the html:
<div id="recipes">
<div class="recipeContainer">
<img src="img/placeholder.png"/>
<ul>
<li>Name</li>
</ul>
</div>
<script id="recipeTemplate" type="text/template">
<img src="<%= image %>"/>
<ul>
<li><%= name %></li>
</ul>
</script>
</div>
There also isn't any errors popping up.
Upvotes: 1
Views: 36
Reputation: 55750
2 issue with your code..
First backbone
has a hard dependency on underscore
.
The order in which you load the library is important
---> Underscore
---> Backbone
Looks like you were loading backbone first.
2nd issue is that you have this in your template <%= image %>
Where as image
attribute not available neither in the array of objects of the default attributes.
Replace that with <%= url %>
instead. That should get the code working.
Also I prefer passing the collection while initializing the view. This has nothing to do with the error though.
var recipesView = new RecipesView({
collection : new Recipes(recipes)
});
Upvotes: 2