Ember select for belongsTo不更新hasMany结束

编程入门 行业动态 更新时间:2024-10-25 14:29:26
本文介绍了Ember select for belongsTo不更新hasMany结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用内置的ember选择视图来更改belongsTo。但是,当选择框更改只有属性属性被更新,而不是hasMany关系。以下jsbin显示此行为 jsbin/ewosiy/3/edit 。

I'm trying to change a belongsTo using the built in ember select view. However, when the select box changes only the belongs to attribute is updated, not the hasMany relationship. The following jsbin shows this behaviour jsbin/ewosiy/3/edit.

在这个例子中,一个人有许多事件和事件属于一个人。如果我更改了该事件属于哪个,则事件将从原始人员中删除,但从未添加到新人员。

In this example a person hasMany events and an event belongsTo a person. If I change who the event belongsTo, the event is removed from the original person but never added to the new person.

我可以滚动自己的选择框组件,但只是想知道Ember选择是否真的不会更新关系的两端。

I could roll my own select-box component but just wondered if the ember select really is not updating both ends of the relationship.

谢谢。

推荐答案

为了使其工作,您需要在person对象的关系中使用pushObject,您需要执行以下操作:

in order to make it work, you need to use 'pushObject' in the relation of your 'person' object, you would need to do something like this:

将您的选择更改为:

{{view Ember.Select contentBinding=controllers.application.model optionValuePath=content.id optionLabelPath=content.fullName selectionBinding=selectedPerson}}

并在你的eventController中添加以下内容:

and in your eventController add this:

selectedPersonChanged: function() { if(this.get('selectedPerson')) { this.get('selectedPerson.events').pushObject(this.get('content')); } }.observes('selectedPerson')

更多推荐

Ember select for belongsTo不更新hasMany结束

本文发布于:2023-10-21 17:21:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1514858.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:结束   select   Ember   hasMany   belongsTo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!