I’m trying to build an observer to detect when changes deep in a table model occur. I can get notifications on “rows.@each.label” but not on “rows.@each.cols.@each.label”.
App.Row = Ember.Object.extend({
init: function () {
this.set('cols', []);
}
});
App.Col = Ember.Object.extend({
label: null
});
var doneWithSetup = false;
var table = Ember.Object.create({
rows: [],
colLabelChanged: function () {
if (doneWithSetup) console.log("IT WORKED! I got notified when a col label changed");
}.observes("rows.@each.cols.@each.label")
});
var row = App.Row.create({});
var col1 = App.Col.create({ label: "Label 1" });
var col2 = App.Col.create({ label: "Label 2" });
row.get('cols').pushObject(col1);
row.get('cols').pushObject(col2);
table.get('rows').pushObject(row);
// OK, lets try this observer out...
doneWithSetup = true;
col1.set('label', 'some new label');
// FIXME: how do I get colLabelChanged to fire???
You can try it here:
Am I doing something wrong or are multi-level @each observers not supported?
This is a bug in EmberJS 0.9.8.1: https://github.com/emberjs/ember.js/issues/541