![](/img/trans.png)
[英]extJS - Call a function from another function within the same controller
[英]ExtJs 4 call functions from another controller synchronously
當我嘗試在控制器中執行此代碼時:
epgES.getApplication().getController('epgES.controller.EPGController').newEditorRequest();
epgES.getApplication().getController('epgES.controller.EPGController').updateViewRangeControl(Ext.Date.parseDate(eventStart, "c"));
第一行必須初始化我的控制器,創建一個視圖並加載所有存儲,而第二行只需調用控制器的功能之一並在控制器完全加載后更改日期范圍。 但是我注意到第二行在第一行尚未完成時執行,而我想要實現的所有邏輯都被破壞了。 如何處理此問題並“同步”執行這兩種方法?
這是瀏覽器工作的預期行為和異步特性。
這樣做的原因是因為瀏覽器在服務器響應后沒有等待執行下一行代碼。 您可以在加載網頁時看到這一點:您可以在有時甚至顯示圖像之前就開始閱讀文本。
在updateViewRangeControl
中執行的代碼(並期望我假設是完全加載的商店)必須在存儲在newEditorRequest
中的商店的load
偵聽器中newEditorRequest
。
檢查這個出來。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.