I have an Ember object which has multiple properties of which some are Ember objects themselves. I need to recursively loop through this structure with a common method work()
to these objects. Therefor I created an Ember mixin.
App.mix = Ember.Mixin.create({
work: function () {
for (var key in this) {
if ( this[key].isMix() ) // !!!
this[key].work();
else
/* do stuff */
}
}
});
App.obj = Ember.Object.extend(App.mix, {
prop1: 'foo',
prop2: 'bar',
child: null
});
test = new App.obj;
test.child = new App.obj;
test.work();
The problem now is, that I need to determine inside the loop, which of the properties of a parent object is another Ember object. If I found one, I need to call .work()
on it.
The question is, how to determine if a object is of the mixin, or has the property work
.
Example for the issue: http://ift.tt/1NBwFlq
Aucun commentaire:
Enregistrer un commentaire