首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Ember.Select设置关联ID

如何使用Ember.Select设置关联ID
EN

Stack Overflow用户
提问于 2012-03-11 04:35:34
回答 1查看 1.4K关注 0票数 5

我正在尝试使用Ember.Select控件在模型上设置关联id。但是,我似乎无法让控件将其选择绑定到id属性,而不是整个模型对象。这是在Ember.Select控件中设计的吗?我的模板中有以下内容:

代码语言:javascript
复制
  {{view Ember.Select
         contentBinding="App.peopleController.content"
         selectionBinding="App.selectedPersonController.personId"
         optionLabelPath="content.fullName"
         optionValuePath="content.id"}}

但是,即使显式地将selectionBinding设置为personId属性,它似乎仍然绑定到person对象。完整的jsfiddle在这里:http://jsfiddle.net/PXVZb/10/

EN

回答 1

Stack Overflow用户

发布于 2012-03-11 17:04:47

我建议将所选的person绑定到您的App.selectedPersonController,并创建一个绑定到person id的属性personId,请参阅http://jsfiddle.net/PXVZb/11/

JS:

代码语言:javascript
复制
App.selectedPersonController = Ember.Object.create({
    personIdBinding: 'person.id'
});

车把:

代码语言:javascript
复制
{{view Ember.Select
       contentBinding="App.peopleController.content"
       selectionBinding="App.selectedPersonController.person"
       optionLabelPath="content.fullName" }}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9649976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档