我想破坏标签面板的内容,因为当我再次打开面板时,它仍然是之前的内容。所以它显示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分钟!谢谢! –