mercredi 27 mai 2015

Ember Data - How to observe for parent model change from child model

I want to observe for changes in a isParentValid-property of parent's model, and update the isChildValid-property of child model base on that.

I want to do something like below.

Parent Model

export default DS.Model.extend({
    child: DS.hasMany('child', { inverse: null }),
    isParentValid: DS.attr('boolean', {defaultValue: false})
});

child Model

export default DS.Model.extend({
    isChildValid: Ember.computed('parent.isParentValid', {
    get: function () {
        //return true if isParentValid property is true
        //else return false
     })
});

Tried few ways not able to figure it out. I am not even sure that if it is even possible




Aucun commentaire:

Enregistrer un commentaire