2015-08-24 25 views
0

有沒有一個班輪會給我一個當前控制器的父應用程序的引用,而不使用父應用程序的名稱?有些東西喜歡this.getParent?什麼我最終要做的是在Extjs中,如何獲得對父應用程序的引用?

this.parentapp.getController('aChildsController').someMethod(); 
+0

請參閱:https://www.sencha.com/forum/showthread.php?179340-Why-does-this.getApplication().getController(-MainController-).testFunction()-fail –

回答

2

是的,你可以簡單地使用this.getApplication(),甚至更短this.app

1

您可以使用this.lookupReference('referenceId')。up() 這將返回直接的祖先容器。

0

我沒有測試在extjs5以下,但這部作品在extjs6經典:

Ext.app.Application.instance.getController(...)。

這允許您在不知道應用程序名稱的情況下獲取對應用程序的引用。

相關問題