当我更改字段时,从哪个设置观察者,观察者不运行
App = Ember.Application.create();
App.Meeting = Em.Object.extend({
id: null,
name: null,
proposes:{choice:5}
});
App.Meeting.reopen({
proposedChanged: function() {
var proposes = this.get('proposes');
console.log(proposes);
Ember.set(proposes, 'yesProcent', 'width:'+proposes.choice+'%');
//this.set('proposes','width:'+10+'%');
console.log(this);
}.observes('proposes')
});
Ember.MyButton = Ember.Button.extend({
click:function(){
var meeting = this.get("meeting");
meeting.proposes.choice = 10;
Ember.set(meeting.proposes, 'choice', 10);
meeting.set('proposes',meeting.proposes);
console.log(meeting.proposes);
}
});
App.meetingsController = Ember.ArrayController.create({
content: [],
loadList: function(){
var me = this;
var m = App.Meeting.create();
m.setProperties({
id : 1,
name : 'Test',
proposes: {choice:5}
});
me.pushObject(m);
}
});
App.meetingsController.loadList();
从我的项目中,有类似的代码,并且当火观察者属性(观察者发生变化)也没有改变(对于那个例子,我的意思是属性 yesProcent)。为什么?
源到示例jsbin