最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ExtJS: Destroy window with config 'closeAction' set to 'hide' - Stack Overflow

programmeradmin0浏览0评论

I have a window with closeAction configured to 'hide' on instantiation:

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

Calling close() on myWin therefore simply hides the window. I need to destroy the window in the sense of destroy as implied by the Sencha docs:

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.

What did I try? I tried:

  1. calling destroy directly on the window object:

    myWin.destroy();
    
  2. setting closeAction to destroy prior to calling close():

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

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

I have a window with closeAction configured to 'hide' on instantiation:

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

Calling close() on myWin therefore simply hides the window. I need to destroy the window in the sense of destroy as implied by the Sencha docs:

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.

What did I try? I tried:

  1. calling destroy directly on the window object:

    myWin.destroy();
    
  2. setting closeAction to destroy prior to calling close():

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

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

Share Improve this question asked Mar 8, 2013 at 11:44 Joseph Victor ZammitJoseph Victor Zammit 15.3k13 gold badges80 silver badges104 bronze badges 4
  • With destroy() it is perfectly destroyed: jsfiddle.net/5BcBd/1. – VisioN Commented Mar 8, 2013 at 11:55
  • @VisioN Thank you for your comment. How are you checking whether it's simply hidden or actually destroyed? In my case, I'm able to re-show the window, that's why I ascertain it's hidden and not destroyed. – Joseph Victor Zammit Commented Mar 8, 2013 at 12:40
  • 1 I have updated the fiddle in the comment above so that is displays the contents of body before and after removal. Typically you may use Chrome DevTools or Firebug for that. In case of destroy() the DOM structure is removed and if you try to call show() afterwards, the JS will raise an error. – VisioN Commented Mar 8, 2013 at 13:46
  • Indeed you're right; please add this as answer, stating clearly that what I assert about destroy() in my question is incorrect - I'll mark your answer as the correct answer. Thanks! – Joseph Victor Zammit Commented Mar 8, 2013 at 14:32
Add a comment  | 

2 Answers 2

Reset to default 10

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

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

Are you want to destroy the window.use below code

Ext.getCmp('Window Id').destroy();    
发布评论

评论列表(0)

  1. 暂无评论