ember.js - Ember select for belongsTo doesn't update hasMany end -
i'm trying change belongsto using built in ember select view. however, when select box changes belongs attribute updated, not hasmany relationship. following jsbin shows behaviour http://jsbin.com/ewosiy/3/edit.
in example person hasmany events , event belongsto person. if change event belongsto, event removed original person never added new person.
i roll own select-box component wondered if ember select not updating both ends of relationship.
thanks.
in order make work, need use 'pushobject' in relation of 'person' object, need this:
change select this:
{{view ember.select contentbinding=controllers.application.model optionvaluepath=content.id optionlabelpath=content.fullname selectionbinding=selectedperson}}
and in eventcontroller add this:
selectedpersonchanged: function() { if(this.get('selectedperson')) { this.get('selectedperson.events').pushobject(this.get('content')); } }.observes('selectedperson')
Comments
Post a Comment