Execute code once after all views have completely rendered in Ember.js

后端 未结 3 631
慢半拍i
慢半拍i 2021-01-05 02:15

Something like document ready, but after all Ember views rendering

I am doing this right now with an override on ApplicationView didInsertElement, which seems to be

3条回答
  •  太阳男子
    2021-01-05 02:41

    You can easily add a "post render" hook by reopening the base View class and adding it into the render queue.

    Here's some code to show you how:

    Ember.View.reopen({
        didInsertElement : function() {
            this._super();
            Ember.run.scheduleOnce('afterRender', this, this.didRenderElement);
        },
        didRenderElement : function() {
            // Override this in your View's
        }
    });
    

提交回复
热议问题