Ember.js Ember.Select valueBinding将multiple设置为true不起作用
我从网上得到了这个演示。它是一个具有指定值的选择框Ember.js Ember.Select valueBinding将multiple设置为true不起作用,ember.js,Ember.js,我从网上得到了这个演示。它是一个具有指定值的选择框 App.programmers = [ Ember.Object.create({firstName: "Yehuda", id: 1}), Ember.Object.create({firstName: "Tom", id: 2}) ]; App.currentProgrammer = Ember.Object.create({ id: 2 }); 视图: 此案例有效,并且选择了Tom项目 当我将属性:multiple=
App.programmers = [
Ember.Object.create({firstName: "Yehuda", id: 1}),
Ember.Object.create({firstName: "Tom", id: 2})
];
App.currentProgrammer = Ember.Object.create({
id: 2
});
视图:
此案例有效,并且选择了Tom项目
当我将属性:multiple=true添加到Ember.Select时,Tom项仍然处于选中状态。但我希望已经选择了多个项目,因此我将App.currentProgrammer更改为:
但是现在什么都没有被选中。是否要更改valueBinding属性?您可以使用selectionBinding: HTML:
我同意valueBinding仍然不起作用。您可以改用selectionBinding: HTML:
我同意valueBinding仍然不起作用。Github上有一个关于此问题的拉取请求:Github上有一个关于此问题的拉取请求:valueBinding和selectbinding之间有什么区别?selectionBinding绑定整个内容,其中作为valueBinding只绑定值部分,即optionValuewhat'svaluebinding和selectbinding之间的区别?selectionBinding绑定整个内容,其中作为valuebinding仅绑定值部分,即optionValue
{{view Ember.Select
contentBinding="App.programmers"
optionValuePath="content.id"
optionLabelPath="content.firstName"
valueBinding="App.currentProgrammer.id"}}
App.currentProgrammer = [
Ember.Object.create({id: 1}),
Ember.Object.create({id: 2})
];
<script type="text/x-handlebars">
{{view Ember.Select
multiple="true"
contentBinding="App.content"
optionValuePath="content.type"
optionLabelPath="content.label"
prompt="Select a value"
selectionBinding="App.types"
}}
{{#each App.types}}
{{type}}
{{/each}}
</script>
App = Ember.Application.create({});
App.content = [
{label: "This is type 1", type: "type1"},
{label: "This is type 2", type: "type2"}
];
App.types = [
App.content[0], App.content[1]
];