2011-07-15 37 views
1

編輯setActiveItem消失TabPanel卡?

我有延伸的TabPanel視口。在其中,我設置了一個tabBar按鈕來加載另一個名爲subTabPanel的TabPanel。 myApp.views.viewport.setActiveItem(index, options)工作得很好。但是myApp.views.subTabPanel.setActiveItem(index, options)只會在消失之前一分鐘加載相應的面板卡。

奇怪的是,它工作得很好,從subTabPanel的列表項目中做這樣的判斷: this.ownerCt.setActiveItem(index, options) 不過,我想避免這種情況,我想這樣的行動生活裏面的控制器,以堅持MVC。

有關爲什麼卡從控制器調用時消失的任何想法,但不是從包含subTabPanel調用時?

(有問題的subTabPanel卡Ext.Carousel的延伸。)



UPDATE

看起來既subTabPanel及其轉盤被實例化莫名其妙的兩倍,因此,可以成爲問題的重要部分...

回答

1

在這種情況下的答案是防止subTabPanel及其傳送帶的重複創建。

視口現在看起來是這樣的:

myApp.views.Viewport = Ext.extend(Ext.TabPanel, { 
    fullscreen: true, 
    layout: 'card', 
    cardSwitchAnimation: 'slide', 
    listeners: { 
     beforecardswitch: function(cnt, newCard, oldCard, index, animated) { 
      //alert('switching cards...'); 
     } 
    }, 
    tabBar: { 
     ui: 'blue', 
     dock: 'bottom', 
     layout: { pack: 'center' } 
    }, 
    items: [], 
    initComponent: function() { 
     //put instances of cards into myApp.views namespace 
     Ext.apply(myApp.views, { 
      subTabPanel: new myApp.views.SubTabPanel(), 
      tab2: new myApp.views.Tab2(), 
      tab3: new myApp.views.Tab3(), 
     }); 
     //put instances of cards into viewport 
     Ext.apply(this, { 
      items: [ 
       myApp.views.productList, 
       myApp.views.tab2, 
       myApp.views.tab3 
      ] 
     }); 
     myApp.views.Viewport.superclass.initComponent.apply(this, arguments); 
    } 
}); 

而且因爲我已經從items:屬性去掉重複的創造者的TabPanel項目,並把他們的具體的TabBar屬性到視圖類SubTabPanel,TAB2和Tab3(每個都是Ext.TabPanel或Ext.Panel的擴展)。