PDA

View Full Version : Destroy a window on a page with multiple versions of the same windows...?



travisbell
14 Dec 2009, 10:10 PM
Hey guys,

I'm having a seemingly simple problem, hoping someone can elaborate.

I have a page with multiple links that open the same window (just with some different vars). By default, when I am using:


this.hide();

Sure it closes the window but then when I open a another one, the first windows variables are used (I am am pretty sure this is happening since the first window isn't destroyed, only hidden).

If I use:


this.close();

Which I believe properly destroys the element from the dom, none of my windows can be opened any more.

How do I make the window close but still available for new windows?

CrazyEnigma
14 Dec 2009, 10:50 PM
Not too sure how you are creating your object.



var winCfg = {};
Ext.apply(winCfg, originalWinCfg, { // Any missing Configurations });
var win = new Ext.Window(winCfg);


What apply does is takes the originalWinCfg and copies it to winCfg, and any missing configurations, can come from the new config.

This only copies one deep, so if you are trying to mesh other parts, it's a little more complicated - for example listeners.

travisbell
15 Dec 2009, 8:09 AM
Wow, thanks man, that is working perfectly. I wasn't aware of this technique.

Cheers!

ByteLess
15 Dec 2009, 9:54 AM
not sure how did you do it. I am having the same issue.

I have a grid button Add new and on click I am opening another window which have 3 more panels on autoload.

when I close this window using


Ext.getCmp("wn_addBooking").destroy();

or


Ext.getCmp("wn_addBooking").close();

Its somehow hidden and not destroyed completely.

I am using EXTJS 2.x

travisbell
15 Dec 2009, 12:28 PM
I'm just closing them like so (assuming the window var is win like in his example):


win.close();

That's attached to a cancel button in my case.