我有以下代码:
JS:
MapSearch.FiltersList = Ember.Object.extend({
content: [
Ember.Object.create({textValue: "Gender", actualValue: "gender"}),
Ember.Object.create({textValue: "Marital Status", actualValue: "msc105"}),
Ember.Object.create({textValue: "Council Tax Band", actualValue: "thc140"}),
Ember.Object.create({textValue: "Length Of Residency", actualValue: "mhc117"}),
Ember.Object.create({textValue: "Household Composition", actualValue: "mhc110"}),
Ember.Object.create({textValue: "Income Value Banded - Profiling", actualValue: "mgc131"}),
Ember.Object.create({textValue: "Property Value Banded - Profiling", actualValue: "mgc111"}),
Ember.Object.create({textValue: "Property Value Banded - 10% UK", actualValue: "mgc112"}),
Ember.Object.create({textValue: "Landscape Lifestyle", actualValue: "mgc120"}),
Ember.Object.create({textValue: "UK Lifestyle Group", actualValue: "bgc422"}),
Ember.Object.create({textValue: "UK Wealth Group", actualValue: "bgc422"})
]
});
MapSearch.FilterSelect = Ember.Select.extend({
attributeBindings: ['name', 'id'],
contentBinding: 'MapSearch.FiltersList.content'
});
车把:
{{view MapSearch.FilterSelect name="filter_type" id="filter_type" class="filter_type" optionValuePath="actualValue" optionLabelPath="textValue"}}
但是我得到一个空白的选择。我知道我做错了什么,但无法弄清楚是什么。
答案 0 :(得分:2)
尝试使FiltersList
成为ArrayController
并创建实例,而不是使用extend
定义它。
MapSearch.FiltersList = Em.ArrayController.create({
content: [
....
]
})
请注意,您可以通过创建
等绑定来提高效率 contentBinding: Em.Binding.oneWay('MapSearch.FiltersList.content')
如果您的选择输入无法更改内容值。