Let's say I have Ember model object:
App.ModelObject = Ember.Object.extend({
attribute1: null,
attribute2: 0,
attribute3: "",
init: function(){
var self = this;
self._super();
console.log(Ember.keys(self).length);
}
});
var obj = App.ModelObject.create(); //logs to console "0"
Than this happens (and I think it is undesired):
Ember.keys(obj).length; // === 0
obj.set("attribute1", 1);
Ember.keys(obj).length; // === 1
obj.set("attribute1", null);
Ember.keys(obj).length; // === 1
obj.set("attribute2", 0);
Ember.keys(obj).length; // === 1
obj.set("attribute2", null);
Ember.keys(obj).length; // === 2
What I have to do if I want to get all keys (attributes) of model, so it should return ["attribute1", "attribute2", "attribute3"]?
Aucun commentaire:
Enregistrer un commentaire