2011-09-29 2 views
0

내가이 유사한 코드가 실패의 ExtJS 4 개 클래스 로딩은

Ext.define('GG.view.Workbench', { 
    extend: 'Ext.container.Viewport', 
    layout: 'fit', 
    items: [ 
     { 
      xtype: 'container', 
      layout: 'border', 
      items: [ 
       { 
        region: 'center', 
        items: [ 
         Ext.create('GG.view.Foo') 
        ] 
       }, 
       { 
        region: 'south', 
        items: [ 
         Ext.create('GG.view.Bar') 
        ] 
       } 
      ] 
     } 
    ], 

    initComponent: function() { 
     this.callParent(arguments); 
    } 
}); 

무엇 발생하는 두 Ext.create 호출이이 배치 될 때 코드가 작동하지 않습니다.

이것은 내가 크롬에 무엇을 얻을 수 있습니다 :

나는이 Ext.create를 사용하는 가정하고 어떻게
Uncaught TypeError: object is not a function 
(anonymous function) 
Ext.ClassManager.instantiateext-debug.js:6428 
(anonymous function)ext-debug.js:2414 
(anonymous function) 

?

답변

2

당신은 overnesting이고, 당신이해야 할 그 클래스가 생성 될 때마다 실행됩니다 방법 내에서

Ext.define('GG.view.Workbench', { 
    extend: 'Ext.container.Viewport', 
    layout: 'border', 

    initComponent: function() { 
     var me = this; 

     Ext.apply(me, { 
      items : me.buildItems() 
     }); 

     me.callParent(arguments); 
    }, 

    buildItems: function() { 
     return [ 
      { 
       region: 'center', 
       items: [ 
        Ext.create('GG.view.Foo') 
       ] 
      }, 
      { 
       region: 'south', 
       items: [ 
        Ext.create('GG.view.Bar') 
       ] 
      } 
     ]; 
    } 
});