2013-02-18 88 views
2
Ember.VERSION : 1.0.0-rc.1 
Handlebars.VERSION : 1.0.0-rc.3 
jQuery.VERSION : 1.8.2 

這裏是我的模型的一部分:爲什麼@each使模板重新渲染?

first_three: function() { 
    var staples = this.get('staples'); 
    var data = staples.slice(0,3)); 
    return data; 
    }.property('[email protected]') 

我使用的模板:

{{#each staple in album.first_three}} 
    {{#linkTo staples.details staple}} 
     <img {{bindAttr src="staple.object.image_pict"}}> 
    {{/linkTo}} 
{{/each}} 

結果,我有

NS_ERROR_DOM_NOT_OBJECT_ERR: Parameter is not an object 

Error: Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. 

爲什麼?我究竟做錯了什麼?我該如何解決它?

回答

1

NS_ERROR_DOM_NOT_OBJECT_ERR是一個jQuery問題。 Ember依賴於Views中的jQuery。我有一個類似的問題,我的每個循環都在構建不存在的HTML標記(即,我忘記在標記上添加'>')。你的循環是否踢出了任何迭代?那將是一個開始的好地方。