javascript ExtJS:销毁窗口,配置“closeAction”设置为“隐藏”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15293229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 00:14:49  来源:igfitidea点击:

ExtJS: Destroy window with config 'closeAction' set to 'hide'

javascriptextjsextjs4.1

提问by Joseph Victor Zammit

I have a window with closeActionconfigured to 'hide'on instantiation:

我有一个closeAction配置为'hide'实例化的窗口:

var myWin = Ext.create('Ext.window.Window', {
    ...
    closeAction:'hide',
    ...
});

Calling close()on myWintherefore simply hides the window. I need to destroythe window in the sense of destroyas implied by the Sencha docs:

调用close()myWin,因此只是隐藏的窗口。我需要销毁destroySencha 文档所暗示的意义上的窗口:

remove the window from the DOM and destroy it and all descendant Components. The window will not be available to be redisplayed via the show method.

从 DOM 中移除窗口并销毁它和所有后代组件。该窗口将无法通过 show 方法重新显示。

What did I try?I tried:

我尝试了什么?我试过:

  1. calling destroydirectly on the window object:

    myWin.destroy();
    
  2. setting closeActionto destroyprior to calling close():

    win.closeAction='destroy';
    win.close();
    
  1. destroy直接在 window 对象上调用:

    myWin.destroy();
    
  2. 在调用之前设置closeAction为:destroyclose()

    win.closeAction='destroy';
    win.close();
    

In both cases, myWinis simply hidden rather than destroyed. Any thoughts?

在这两种情况下,myWin都只是隐藏而不是销毁。有什么想法吗?

回答by VisioN

Method destroy()should successfully remove the window object from the DOM. In order to illustrate this you can check the basic example in JSFiddle.

方法destroy()应该成功地从 DOM 中删除 window 对象。为了说明这一点,您可以查看JSFiddle 中的基本示例。

After calling myWin.destroy()the structure is cleared and it becomes not possible to reinvoke the window with myWin.show().

调用myWin.destroy()结构被清除后,就无法使用 重新调用窗口myWin.show()

回答by sravan kumar

Are you want to destroy the window.use below code

你想销毁window.use下面的代码

Ext.getCmp('Window Id').destroy();