你可以在路由中定义一个动作
App.ApplicationRoute = Ember.Route.extend({
actions:{
sendRequest:function(){
//send Ajax Request
}
}
});
并在您的帖子路由的 setupController 挂钩中订阅模型事件
App.PostRoute = Ember.Route.extend({
setupController: function(controller, model) {
controller.set('model', model);
model.on('didUpdate',controller,function(){this.send('sendRequest')})
model.on('didCreate',controller,function(){this.send('sendRequest')})
model.on('didDelete',controller,function(){this.send('sendRequest')})
}
});
希望对您有所帮助,这只是一个示例,您可以通过多种方式进行操作,其想法是订阅在服务器响应 POST、PUT 或 DELETE 请求时触发的模型事件
基于你的 JsBin....
OlapApp.OlapRoute = Ember.Route.extend({
setupController(controller,model){
var that = this;
this.store.findAll('axisModel').then(function(axisModel){
axisModel.on('didUpdate',controller,function(){this.send('sendRequest')})
axisModel.on('didCreate',controller,function(){this.send('sendRequest')})
axisModel.on('didDelete',controller,function(){this.send('sendRequest')})
that.controllerFor('OlapColumn').set('model', axisModel);
that.controllerFor('OlapRow').set('model', axisModel);
that.controllerFor('OlapFilter').set('model', axisModel);
});
}
});