Thursday, 15 April 2010

ember.js - Observe change on any attribute of an Ember Data -


Is this possible? .observes ('_data') , but no.

In the case of use, I have a Dicker mixture that has been done since some of the CPs that say how long a model has been updated since I have been To be able to update these CPs if none of the models of the model has changed. isDirty will not work as my use uses store.push to update the case model.

I do not think there is a built-in method to do this, but it is not very difficult to create one Just create a base class for all of your models and override the set function. Something like this:

  var betassodel = DS.Model.extend ({set: function (keyName, value) {var ret = this._super.apply (this, argument); var properties = Ember.get (this.constructor, 'attributes'); if (attributes [keyName]) {this.trigger ('attchangeChanged');} return ret;}}); After that, you can listen to changes in any of the attributes like this:  
  model.on ('attribute', 'function' (function } {});  

I think you can do anything like this in the case of a controller or similar object (although I did not test it):

 < Code> controller.extend (amber.miscellaneous, {modelPropertyChanged: function () {} .on ('model.attributeChanged')});  

No comments:

Post a Comment