PDA

View Full Version : newb question using windows



dedoz
27 Jan 2012, 10:04 PM
hi, question is , can i create a window and show/hide many times or i have to create the window everytime i want to show it ? the real window code is large (has many controls) so im trying to avoid creating the window everytime.


i have this example


Ext.define('WindowX', {
extend: 'Ext.window.Window',
title : 'My simple window',
layout: 'fit',
autoShow: false,
modal: true,
height : 100,
width: 100,

});

var myWindow = Ext.create('WindowX');

var button = Ext.create('Ext.Button',
{ text: 'show window',
handler : function(){
myWindow.show();
},
renderTo: Ext.getBody()

});


If i press the button "show window" the windows shows.
Then i press the close window and the window is gone.
And then i press the button "show window" again and i get an error.
Tried with versions 4.07 4.1pr1 4.1beta1 and beta2, so i guess is not a bug? im doing something wrong.

Also if i add a button to the window , and do this.hide(), happens exactly the same as pressing the traditional close window button (X)

josephkirubakaran
27 Jan 2012, 10:36 PM
You can set the closeAction as 'hide'.



Ext.define('WindowX', {
extend: 'Ext.window.Window',
title : 'My simple window',
layout: 'fit',
autoShow: false,
modal: true,
height : 100,
width: 100,
closeAction:'hide'

});

var myWindow = Ext.create('WindowX');

var button = Ext.create('Ext.Button',
{ text: 'show window',
handler : function(){
myWindow.show();
},
renderTo: Ext.getBody()

});

dedoz
27 Jan 2012, 11:11 PM
As i posted, using the hide() method results in the same error. try your code and will raise an error on the second time showing the window.

( i ran your code btw and gives me the same error)

josephkirubakaran
27 Jan 2012, 11:17 PM
As i posted, using the hide() method results in the same error. try your code and will raise an error on the second time showing the window.

( i ran your code btw and gives me the same error)

Can you provide your actual code piece? bocz when i ran my code am not getting any errors.

dedoz
27 Jan 2012, 11:27 PM
my bad i diserve to die and u diserve heaven.

i didnt put ur line on my second test.
thanks , ill throw myself from the window

josephkirubakaran
27 Jan 2012, 11:31 PM
Still am not getting any errors.

I have tested the same code with firefox 6.0 and IE 9 and the Ext Js version is 4.0.7

josephkirubakaran
27 Jan 2012, 11:37 PM
:) Enjoy!!