mardi 3 mars 2015

Iterating over the values of a controller's model

I need to iterate over the values of a model in code prior to saving. The only way I have been able to do this is as follows:



var changedAttributes = this.model.changedAttributes();
var hasChanges = false;
Ember.keys(changedAttributes).forEach(function(key) {
var values = changedAttributes[key];
var newValue = values[1];
if (!Ember.isEmpty(newValue)) return hasChanges = true;
});
return hasChanges;


This does not seem optimal. Is there a more efficient way to loop over all existing values of a model please?





Aucun commentaire:

Enregistrer un commentaire