2013-04-21 46 views
1

我使用RESTAdapter模型来填充Ember的select选项。使用RESTAdapter时,Ember的选择选项是错误的

contentBinding被映射到控制器中的一个属性,我使用this.set('myProperty',model.find(someQuery))。

model.find(someQuery)带有1个结果,但是model.find(someQuery)带有许多结果会产生奇怪的效果。结果中的最后一个对象显示的次数与结果的长度一样多。

{{视图Ember.Select contentBinding = “myProperty的” optionValuePath = “content.id” optionLabelPath = “content.name” selectionBinding = “selectedResult” 提示=”“}}

回答

3

有趣。乍一看,你在问题中包含的代码看起来很好。调试:

1)检查以确保查询结果符合您的预期。

content = model.find(someQuery); //with many results 
// wait for results... 
console.log(content.getEach('id')); //expect array of ids 
console.log(content.getEach('name')); //expect array of names 

2)检查myProperty的内容 - 从模板:

{{#each myProperty}} 
    <pre>{{id}}.{{name}}</pre> 
{{/each}} 

期待模板来输出ID /名称为每个选项。

+0

谢谢Mike。对于数组的所有对象,id是相同的(doh !!)。 – Jacob 2013-04-21 21:13:58

相关问题