我想破壞標籤面板的內容,因爲當我再次打開面板時,它仍然是之前的內容。所以它顯示2個相同的內容。Extjs,如何刪除標籤面板的內容
所以我想把代碼銷燬標籤面板內容到beforeclose事件處理程序。
,我試圖這樣,
tempTab.on('beforeclose',function(obj){
this.items.each(function(c){this.remove(c)});
});
,但它不工作。
任何人都可以幫忙嗎?
源:
ManuBar區(MENU)
menubar.add({
text : 'Administrator',
iconCls : 'plugin',
menu : {
items : [
{
text : 'Menu Management',
id : 'menuManagement',
iconCls : 'tabs',
url : 'main/test2',
handler : onMenuClick
},{
text : 'User Management',
id : 'useManagement',
iconCls: 'user',
url : 'main/test',
handler : onMenuClick
}]
}
})
馬努處理程序
function onMenuClick(item) {
if(!Ext.getCmp('tab_'+item.id)){
var tempTab = Ext.getCmp('mainTabPanel').add({
id : 'tab_'+item.id,
margins : '0 5 5 0',
deferredRender : false,
closable : true,
title : item.text,
plain : true, //
defaults : {autoScroll : true},
autoLoad : {
url : '/ext/main/test2/',
scripts : true
},
listeners : {
'beforeclose' : function(){
alert(this.items.get(0).id); // output : testPanel
this.removeAll();
alert(this.items.get(0).id); // output : undefined
}
}
});
tempTab.on('beforeclose',function(){
//console.log(this);
this.removeAll(); ////////////////////////////////////
});
Ext.getCmp('mainTabPanel').setActiveTab(tempTab);
}else {
var tempTab = Ext.getCmp('tab_'+item.id);
Ext.getCmp('mainTabPanel').setActiveTab(tempTab);
}
}
和內容(test2.php)(其加載使用自動加載和腳本:true)
test = function(){
return {
init : function() {
Ext.QuickTips.init();
var app = new Ext.Panel({
id : 'testPanel',
html : 'My Second Panel'
});
var tab = Ext.getCmp('tab_menuManagement');
//app.relayEvents(tab, ['activate', 'deactivate', 'beforeclose']);
tab.add(app);
tab.doLayout();
tab = null; app = null;
}
}
}();
Ext.onReady(test.init, test, true);
我認爲該項目成功刪除。但仍然在關閉並再次打開選項卡時。 它顯示2個相同的內容。
我的第二面板 我的第二面板
我不知道什麼是錯....
---更新---
我改變了test2.php文件中像這
var tab = Ext.getCmp('tab_menuManagement');
tab.removeAll(); // I added
tab.add(app);
tab.doLayout();
然後它的工作。有點奇怪。在關閉之前,它被刪除。但如何 它再次活着.... ??任何人幫助?
謝謝!
我只是試過,但它不工作.. –
分享更多的來源.. – TheHorse
好吧,我會編輯我的問題。請給我5分鐘!謝謝! –