现在updateChartObserver
在价值mHours
aHours
发生变化时有效。
我想在DOM准备就绪时执行updateChartObserver
函数。
由于
{{input type='text' value=mHours}}
{{input type='text' value=aHours}}
App.ApplicationRoute = Ember.Route.extend({
model: function(){
// Ember.A() just a way to define an Ember
return Ember.A([
Ember.Object.create({'letter':'Manual working hours', 'num':0 }),
Ember.Object.create({'letter':'Automating working hours', 'num':0 }),
Ember.Object.create({'letter':'Saving hours/round', 'num':0 }),
Ember.Object.create({'letter':'Saving hours/year', 'num':0 }),
]);
}
});
App.ApplicationController = Ember.ArrayController.extend({
mHours: 20,
aHours: 5,
savingHours:function(){
return this.get("mHours")*5;
}.property('mHours'),
updateChartObserver: function(){
data = this.get('model');
data[0].set("num", this.get("mHours"));
data[1].set("num", this.get("aHours"));
}.observes('mHours','aHours'),