如何在Ember.js中重新加载当前路由? [英] How to reload current route in Ember.js?
本文介绍了如何在Ember.js中重新加载当前路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
App.PlaylistRoute = Ember.Route.extend {
setupController:function(controller,model){
$ .getJSON('api / playlist.php?'+ Math.random()。toString(36),function(data){
controller.set('model',data);
});
}
});
非常感谢!
解决方案
从控制器使用 transitionToRoute
:
this.transitionToRoute('playlist',newModel);
从路由使用 transitionTo
:
this.transitionTo('playlist',newModel);
例如,假设您在控制器上有一个操作
App.PlaylistController = Ember.ArrayController.extend({
actions:{
grabNewModel:function(){
// get some新模型
this.transitionToRoute('playlist',newModel);
}
}
});
in Ember.js I have route with model. Could you help me, when I'm on route playlist how to reload this route (or set new data to model) called by callback from another JS function? I've been looking to documentation so long, but no help for me.
App.PlaylistRoute = Ember.Route.extend({
setupController: function(controller, model) {
$.getJSON('api/playlist.php?' + Math.random().toString(36), function (data) {
controller.set('model', data);
});
}
});
Thanks a lot!
解决方案
From a controller use transitionToRoute
:
this.transitionToRoute('playlist', newModel);
From a route use transitionTo
:
this.transitionTo('playlist', newModel);
For example, imagine you have an action on your controller
App.PlaylistController = Ember.ArrayController.extend({
actions: {
grabNewModel: function(){
//get some new model
this.transitionToRoute('playlist', newModel);
}
}
});
这篇关于如何在Ember.js中重新加载当前路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文