2012-04-23 143 views
2

语法试图迄今多选低于,即包括多个=“多”语法灰烬多选

{{view Ember.Select multiple="multiple" 
    contentBinding="App.viewPersonController" 
    selectionBinding="App.selectedPersonController.person" 
    optionLabelPath="content.personName" 
    optionValuePath="content.id" 
    prompt="Select..." }} 
{{/view}} 

下面是错误:

未捕获的错误:断言失败:选择多是假的,但是你已经指定了一个数组选择。

如何制作多个true

回答

3

除了你的把手模板的问题 - {{view}}不能用结束标签关闭,但{{#view}}{{/view}}需要 - 你提供的代码工作正常。 multiple是一个布尔值,因此所有评估为true的值都将设置为true。这就是为什么分配multiple的原因。我也删除了prompt,因为它混淆了多个选择。我想这是一个错误。见http://jsfiddle.net/pangratz666/p4QfQ/

把手

{{view Ember.Select 
    multiple="true" 
    contentBinding="App.viewPersonController" 
    selectionBinding="App.selectedPersonController.persons" 
    optionLabelPath="content.personName" 
    optionValuePath="content.id"}} 

的JavaScript

App.viewPersonController = Ember.ArrayProxy.create({ 
    content: [{personName: 'Alf', id: 1}, {personName: 'Brian', id: 2}] 
}); 

App.selectedPersonController = Ember.Object.create({ 
    persons: [] 
});​ 

view把手助手的注意事项:如果你通过{{view ClassName}}指定视图你告诉把手可呈现特定视图ClassName,其中模板在视图的类上被定义为templateName或预编译为template

通过{{#view ClassName}} template instructions {{/view}}声明一个视图,您正在为显式定义视图的模板。

+0

感谢帮手澄清,并解决了问题 – user1338121 2012-04-23 08:14:39