jQuery suggests在執行任何DOM操作之前等待文檔ready
事件。在flight.js組件中,this.after('initialize')
似乎在該事件觸發之前被調用。flight.js組件應等待document.ready?
是否有必要在飛行組件內等待它,像這樣?
this.after('initialize', function() {
// Is this necessary?
$(document).ready(function() {
...
});
// Or this, the flight way?
this.on(document, 'ready', function() {
...
});
});
謝謝
這裏有太多的上下文來理解這段代碼試圖做什麼。例如,代碼片段中的「this」是什麼?什麼是'.after()'方法,什麼時候調用? – jfriend00
使用'.on()'偵聽'ready'事件從jQuery 1.8開始被棄用。這個事件的支持形式被列出[這裏](https://api.jquery.com/ready/)。 '$(document).ready()'是受支持的表單之一。 – jfriend00
請查看https://github.com/flightjs/flight,看看我在問什麼。爲了清晰起見編輯了這個問題。 – Rudi