Web applications 有没有办法获取ExtJS 4.0应用程序中的所有控制器
我正在使用ExtJS4.0的新MVC架构构建一个应用程序。我正在寻找一种方法来迭代应用程序中的所有控制器。下面我放了一些示例代码,让大家了解我正在尝试做什么Web applications 有没有办法获取ExtJS 4.0应用程序中的所有控制器,web-applications,extjs,extjs4,Web Applications,Extjs,Extjs4,我正在使用ExtJS4.0的新MVC架构构建一个应用程序。我正在寻找一种方法来迭代应用程序中的所有控制器。下面我放了一些示例代码,让大家了解我正在尝试做什么 Ext.application({ name: 'MyApp', appFolder: '/App', controllers: [ 'HdMenuItemsController' ], launch: function () { //This works:
Ext.application({
name: 'MyApp',
appFolder: '/App',
controllers: [
'HdMenuItemsController'
],
launch: function () {
//This works:
this.getController('HdMenuItemsController')
//I want to do something like this:
this.controllers.each(myFunction);
//or this:
this.getAllControllers().each(myFunction);
//or this:
Ext.getControllersForApp(this).each(myFunction);
}
});
据我所知,没有内置的方式(我有点好奇为什么需要这样做),但您可以按如下方式完成此操作(如示例中所示,将其放入
launch()
函数中):
据我所知,没有内置的方式(我有点好奇为什么需要这样做),但您可以按如下方式完成此操作(如示例中所示,将其放入
launch()
函数中):
this.controllers.each(function(item, index, length){
var myController = this.getController(item.id);
//now do something with myController!
//OR:
this.getController(item.id).someFunction();
//where someFunction() is defined in all of your controllers
});