mercredi 2 septembre 2015

How to observer base component property

Here is simple code (Ember 1.13.7):

Main component:

export default Ember.Component.extend({
  tagName: 'a',
  classNameBindings: ['isTestCom:test'],
  didInsertElement: function() {
    this._super.apply(this, arguments);
    this.$().on('click', Ember.run.bind(this, function() {
      this._click();
    }));
  },
  willDestroyElement: function() {
    this._super.apply(this, arguments);
    this.$().off('click');
  },

  _click:function(){
    this.toggleProperty('isTest');
  },
  isTest:false,
  isTestCom: Ember.computed('isTest',function(){
    return this.get('isTest');
  }),
});

Extended component:

export default MainComponent.extend({
  isTestChid: Ember.computed('isTestCom',function(){
    console.debug('working');
  })
});

The problem is that isTestChild never fires. Any idea how to observer mains component properties would be very helpful




Aucun commentaire:

Enregistrer un commentaire