2011-09-21 3 views
2

저는 ExtJS 4.0의 새로운 MVC 아키텍처를 사용하여 응용 프로그램을 작성하고 있습니다. 나는 애플 리케이션의 모든 컨트롤러를 반복하는 방법을 찾고 있어요. 아래 코드는 내가하려고하는 것에 대한 아이디어를주기 위해 몇 가지 샘플 코드를 넣었다.ExtJS 4.0 응용 프로그램에서 모든 컨트롤러를 가져 오는 방법이 있습니까?

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); 


     } 
    }); 

답변

0

는 아니 내가 아는 방법으로 내장 없다 (그리고 나는 당신이이 작업을 수행 할 필요가 왜 좀 궁금하다),하지만 당신은 당신의 예제에있는대로 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 
}); 
관련 문제