Ember.js 余烬。选择值更改时不触发可观察

Ember.js 余烬。选择值更改时不触发可观察,ember.js,handlebars.js,Ember.js,Handlebars.js,我有一个Ember.Select,将valueBinding设置为数组中的项属性。函数正在观察此属性。尽管属性的值已更改,但该函数在选择更改后不会被激发 手杖: Javascript: 这个jsbin更清楚地显示了这一点: 我想在observes函数中完成的是过滤第二个Ember.Select。这条路对吗?我怎样才能使这个jsbin工作 感谢您的任何输入。问题在于,在使用Ember.Object.extend定义类时,您试图在Ember.Object.create中定义一个观察者,而这通常是完成

我有一个Ember.Select,将valueBinding设置为数组中的项属性。函数正在观察此属性。尽管属性的值已更改,但该函数在选择更改后不会被激发

手杖:

Javascript:

这个jsbin更清楚地显示了这一点:

我想在observes函数中完成的是过滤第二个Ember.Select。这条路对吗?我怎样才能使这个jsbin工作


感谢您的任何输入。

问题在于,在使用Ember.Object.extend定义类时,您试图在Ember.Object.create中定义一个观察者,而这通常是完成的。您可以这样定义一个类:

var TmpDocument = Ember.Object.extend({
然后从中实例化您的tmpDocument实例,或者您需要在创建文档后将观察者添加到文档中,就像我在中所做的那样:

window.App = Ember.Application.create();

App.documentCategories = [];
App.documentCategories.push({label: 'A', value: '1'},{label: 'B', value: '2'});

App.uploadedDocuments = Ember.A();

var tmpDocument = Ember.Object.create({
    Category: 0,
    CategoryDidChange: function() {
            console.log('Category changed to: ' + this.Category);
        }.observes('Category')
});

App.uploadedDocuments.addObject(tmpDocument);
var TmpDocument = Ember.Object.extend({
tmpDocument.addObserver('Category', function() {
  console.log('Category changed to: ' + this.Category);
});