Solved: How to observe a model property change in controller?

Hi there,

I am fetching a list of objects with Ember-Data within the model hook of a route. Each object (‘item’) has a property ‘checked’ (checked: DS.attr(‘boolean’, { defaultValue: false }),) Then I put the list as ‘list’ to the controller. In template I loop through the list and display the records while adding the ability to check/uncheck an item. {{input type=“checkbox” checked=item.checked}} How do I observe if one or more items in my list got checked inside my controller in order to enable a - lets say - action button?

updated: function () { Ember.Logger.info(“Beep!”); }.property(‘list.@each.checked’)

does not get fired.

TIA,

Martin

P. S.

This works:

// ---------------------------------------------------------------------------
isActionButtonDisabled: function () {
var disabled = true;
    var enumeration = this.get('list').map(function (item, index, enumerable) {
      if (item.get('checked')) {
        disabled = false;
      }
    });
    return disabled;
  }.property('list.@each.checked'),

The code you said works is the same as the code you said didn’t - can you explain which one you are using and what you expect to happen?

Good point, Alex! So for clarification: The working observer stuff above will not be triggered automatically. It fires only if you bind item.checked to the input field. That was what I forgot in the first place… :-/

Regards,

Martin