mercredi 23 mars 2016

How do you create a computed property in Ember.js to see if a single Ember Data attribute is dirty?

I've tried creating a computed property on an Ember Data 1.13.16 model like this:

export default DS.Model.extend({
  name: DS.attr('string'),
  isNameDirty: Ember.computed('name', 'hasDirtyAttributes', function() {
    return !!this.changedAttributes()['name'];
  })
});

But for some reason, after calling model.save() the property never recomputes to false, even though name is no longer present in changedAttributes(). How can I make this computed property work?

Here's a reduced test case: http://ift.tt/1MCISGM




Aucun commentaire:

Enregistrer un commentaire