gpt4 book ai didi

ember.js - 如何处理加载结束事件?

转载 作者:行者123 更新时间:2023-12-02 06:09:08 25 4
gpt4 key购买 nike

我有以下测试应用程序,实现 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();
},

}
});

哪个按预期工作:UI 被 loading 阻止事件。

如何解锁 UI ( $.unblockUI() )?有没有 loadingFinished (或类似的) Action ,我可以在所有模型完成解析时执行吗?

工作jsbin here .

最佳答案

Legacy Loading Route为例你可以:

App.ApplicationRoute = Ember.Route.extend({
beforeModel: function() {
return delayedPromise();
},

actions: {

loading : function() {
$.blockUI();
this.router.one('didTransition', $, 'unblockUI');
},

}
});

关于ember.js - 如何处理加载结束事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27949635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com