我有以下测试应用程序,实现loading事件:
App = Ember.Application.create();
function delayedPromise(delay, value) {
delay = delay || 3000;
value = value || { msg: 'Delayed promise has been fulfilled' };
var promise = new Ember.RSVP.Promise(function(resolve) {
Ember.run.later(function() {
console.info('Delayed promise has been fulfilled');
resolve(value);
}, delay);
});
return promise;
}
App.ApplicationRoute = Ember.Route.extend({
beforeModel: function() {
return delayedPromise();
},
actions: {
loading : function() {
$.blockUI();
},
}
});
哪个工作符合预期:用户被loading
事件阻止。
如何取消阻止用户界面($.unblockUI()
)?是否有loadingFinished
(或类似的)操作,只要所有模型都已完成解析,我就可以实现它?
工作jsbin here。
答案 0 :(得分:2)
按照Legacy Loading Route的例子,您可以:
App.ApplicationRoute = Ember.Route.extend({
beforeModel: function() {
return delayedPromise();
},
actions: {
loading : function() {
$.blockUI();
this.router.one('didTransition', $, 'unblockUI');
},
}
});