1

未顯示應該顯示的js應用程序。查看不與數據呈現

這裏的應用:http://jsfiddle.net/5sded/

應該通過配方來循環,而是它不顯示任何東西。這裏的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> 

也沒有任何彈出錯誤。

回答

2

2問題與您的代碼..

首先backbone硬依賴underscore

在其中加載庫的順序很重要

---> Underscore 

---> Backbone 

看起來你是第一次加載骨幹。

Check Fiddle

第二個問題是,你在你的模板<%= image %>

凡爲image屬性不可用的默認屬性的對象數組既不具備這一點。

改爲用<%= url %>代替。這應該讓代碼工作。

另外我更喜歡在初始化視圖時傳遞集合。但這與錯誤無關。

var recipesView = new RecipesView({ 
    collection : new Recipes(recipes) 
}); 
+0

這是一個很好的答案感謝您的幫助! –

+0

很高興我可以幫忙:) –