samedi 5 mars 2016

Ember.computed not triggered on @each

I'm having trouble with Ember.computed reacting to a field value change in an array of objects. I have a component with the following pieces of code

init(){
     ...
     this.set('colors', defaultColors.map(function(color){
        return Ember.Object.create({
            value: color,
            isSelected: false
        });
     });
     ...
}
...
filtered: Ember.computed(function(){
    console.log('change');
}).property('colors.@each.isSelected');

Then in my template I have

{{#each colors as |color|}}
    {{color-component model=color}}
{{/each}}

And my color component contains

click(){
    this.set('model.isSelected', !this.get('model.isSelected'));
    console.log(this.get('model.isSelected'));
},

When I click on the color component I see the console log with the model.isSelected being changed, but I don't see the console log from within Ember computed. What am I doing wrong? Thanks!




Aucun commentaire:

Enregistrer un commentaire