我正在使用ExtJs4。銷燬窗口
new Ext.Window({
id: token + '_window',
animateTarget: token + '_taskbar', //Button id
height: 300,
width: 300,
title: name,
maximizable: true,
minimizable: true,
iconCls: 'basketball-small-icon',
html: 'This is the <b>' + name + '</b> window',
listeners: {
'beforeclose': onWindowClose,
'minimize': function(){ this.hide(); }
}
請注意與動畫目標關聯的按鈕。 這裏onWindowClose被定義爲
function onWindowClose(t){
var token = t.id.split('_')[0];
var taskBarItemId = token + '_taskbar';
Ext.getCmp(taskBarItemId).destroy(); //Destroying the button
t.destroy(); //Destroying the window
}
在這裏,我想刪除的窗口和相關的按鈕。 每次我關閉窗口,我有兩個選擇,如下
- 我可以摧毀兩個按鈕和窗口,但有時我不能再打開窗口。我認爲這與該按鈕鏈接到窗口的'animateTarget'這一事實有關。因爲當我刪除這個屬性,這工作正常。
- 我可以使用t.close()而不是t.destroy(),但它會變成遞歸的。我如何調用基本關閉方法?
是否每次銷燬窗口並在每次單擊圖標時使用'new'創建一個好主意? close()和destroy()方法有什麼區別?
你要我不包括t.close()或t.destroy()。 – Shashwat 2012-02-23 12:37:27
@Shashwat不要點擊右上角的'x'按鈕關閉窗口?那麼是的,你不需要調用close()或destroy()。 – 2012-02-23 12:47:16
你想讓我不要包含t.close()或t.destroy()嗎?這是行不通的。它刪除按鈕,但不是窗口和窗口卡住。 我認爲t。如果我在處理程序中調用基本方法close(),close()將被觸發。你能告訴我該怎麼做嗎? – Shashwat 2012-02-23 13:03:56