0

我有以下代码:

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"}}

但是我得到一个空白选择。我知道我做错了什么,但不知道是什么。

4

1 回答 1

2

尝试制作您FiltersList的 anArrayController并创建实例,而不是使用extend.

MapSearch.FiltersList = Em.ArrayController.create({

    content: [
    ....
    ]

})

请注意,您可以通过创建绑定来使事情变得更高效

contentBinding: Em.Binding.oneWay('MapSearch.FiltersList.content')

如果您的选择输入无法更改内容值。

于 2012-12-07T14:25:52.120 回答