如何处理加载结束事件?

How to handle end of loading event?

我有以下测试应用程序,执行 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(或类似的)操作可以在所有模型都完成解析后实施?

工作 jsbin here

按照 Legacy Loading Route 的示例,您可以:

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

  actions: {

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

  }
});