Extjs,如何删除选项卡面板';内容
我想销毁选项卡面板的内容,因为当我再次打开面板时,它仍然是以前的内容。所以它显示了两个相同的内容 因此,我想将销毁选项卡面板内容的代码放入beforeclose事件处理程序中 我试着这样做Extjs,如何删除选项卡面板';内容,extjs,Extjs,我想销毁选项卡面板的内容,因为当我再次打开面板时,它仍然是以前的内容。所以它显示了两个相同的内容 因此,我想将销毁选项卡面板内容的代码放入beforeclose事件处理程序中 我试着这样做 tempTab.on('beforeclose',function(obj){ this.items.each(function(c){this.remove(c)}); }); 但它不起作用 有人能帮忙吗 资料来源: ManuBar区域(菜单) 手动处理程序 function onMenu
tempTab.on('beforeclose',function(obj){
this.items.each(function(c){this.remove(c)});
});
但它不起作用
有人能帮忙吗
资料来源:
ManuBar区域(菜单)
手动处理程序
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)
我认为该项目已成功删除。但当再次关闭并打开选项卡时仍然如此。
它显示两个相同的内容
我的第二个小组
我的第二个小组
我不知道怎么了
---更新---
我像这样更改了test2.php文件
var tab = Ext.getCmp('tab_menuManagement');
tab.removeAll(); // I added
tab.add(app);
tab.doLayout();
然后它就起作用了。真奇怪。在完全关闭之前,它被移除了。但是怎么做呢
它又活了。。。。??有人帮忙吗
谢谢 试着
tempTab.on('beforeclose',function(obj){
this.removeAll();
});
注:
你使用了一些坏习惯。例如:
variabile.on('event', handler, scope)
这将使变量
处于活动状态,因为存在非托管事件(由Ext管理,因为它由您管理)。如果手动侦听事件,则必须在销毁变量
之前卸载它。或者,如果你像我一样(懒惰:-),只需使用this.mon
另一件坏事是
Ext.getCmp
(和id
)——它应该只用于调试目的,而不是用于开发。当我开始使用Ext时,我使用了ID,当我创建多个实例时,我在TabPanel中遇到了非常奇怪的问题。我找不到在什么地方触发beforeclose事件。诱惑ab.on('beforeclose',function(){//console.log(this);this.removeAll();//////;我像这样尝试了警报(this.items.get(0.id))//输出:testPanel this.removeAll();警报(this.items.get(0.id);//输出:未定义。这意味着它被移除了。但当我再次打开选项卡面板时,它显示了两个相同的内容。再次关闭和打开,它显示相同的3个内容。。。。你知道怎么了吗?
tempTab.on('beforeclose',function(obj){
this.removeAll();
});
removeAll( [Boolean autoDestroy] ) : Array
*Removes all components from this container*.
variabile.on('event', handler, scope)