我的模板中有一個Ember.Select。這些選項從我從服務器獲得的內容中填充。所有的選項都很好。但是當我想顯示選定的值時,它會將屬性設置爲undefined。Ember.Select綁定設置爲undefined
模板:
{#with this as context}}
{{#each}}
<tr>
<td>{{name}}</td>
<td>{{view Ember.Select content=context.types optionValuePath='content.id' optionLabelPath='content.name' value=type}}</td>
</tr>
{{/each}}
{{/with}}
控制器:
types: function() {
return this.store.find('myType');
}.property()
型號我通過循環:
DS.Model.extend({
name: DS.attr(),
type: DS.attr() // <= this is the selected type (id)
});
MyType的模型:
DS.Model.extend({
name: DS.attr()
});
此代碼將呈現select元素中的所有選項。像這樣:
<select>
<option value="1">My first type</option>
<option value="2">My second type</option>
</select>
下面的事情我不明白:
- 當我檢查我的數據(燼檢查插件)的屬性類型設置爲undefined。
- 但是,當我選擇一個選項的類型屬性設置爲正確的ID。
- 當我刪除
value=type
時,在檢查數據時,type屬性具有正確的值。
jsbin: http://emberjs.jsbin.com/cugetoxoyira/3/edit
你可以放在一起顯示問題倉:http://emberjs.jsbin.com/ – tikotzky 2014-10-07 23:06:52
加入jsbin:http://emberjs.jsbin.com/cugetoxoyira/3/編輯 – Klaasvaak 2014-10-08 07:39:24