ember 在加载页面后执行js方法
在合适的地方加入一下代码
Ember.run.scheduleOnce('afterRender', this, afterRenderEvent);
afterRenderEvent : function(){
// implement this hook in your own subclasses and run your jQuery logic there
}
可以加在model上
也可以加在view上
App.YourView = Ember.View.extend({
didInsertElement : function(){
this._super();
Ember.run.scheduleOnce('afterRender', this, function(){
// perform your jQuery logic here
});
}
});
也可以重写view对象(对所有view有效)
Ember.View.reopen({
didInsertElement : function(){
this._super();
Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
},
afterRenderEvent : function(){
// implement this hook in your own subclasses and run your jQuery logic there
}
});