PDA

View Full Version : rebuild the window



Stephan123
29 Sep 2009, 6:26 AM
Hello !

I have extended the window object.
When the first time the script load the window do work.



Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = '/lib/extjs3/resources/images/default/s.gif';
Ext.QuickTips.init();

var loginverwaltung = new Ext.Window({
title: 'Test',
width: 400,
height: 400
});

loginverwaltung.show();

});


When i call the 'command loginverwaltung.show();' in the console from the firebug
i became the message:
'ReferenceError: loginverwaltung is not defined'

How can i recall the window ?

Your sincerly

Stephan

BitPoet
29 Sep 2009, 6:33 AM
This is a scope issue, you should read up on scoping of names in javascript, understanding that will spare you a lot of headache. In this case, the variable 'loginverwaltung' is local to the scope of the function passed to Ext.onReady and can not be accessed from outside. To circumvent that limitation without cluttering the global namespace, give your window an explicit id and call


Ext.getCmp('id-of-your-window').show();

Stephan123
29 Sep 2009, 7:09 AM
Hello !

I have change the script


Ext.onReady(function() {
Ext.BLANK_IMAGE_URL = '/lib/extjs3/resources/images/default/s.gif';
Ext.QuickTips.init();

loginverwaltung = new Ext.Window({
title: 'Test',
width: 400,
height: 400,
id: 'fenster'
});

loginverwaltung.show();

});When i type in the firebug console


var wert = Ext.getCmp('fenster');
wert.show();i became the message: 'wert is undefined'

Your sincerly

Stephan

Stephan123
29 Sep 2009, 7:34 AM
Hello !

I have build a new Test 2


var kFenster = function(){

return {

bauFenster: new Ext.Window({
title: 'Fenster',
id: 'fenster',
width: 400,
height: 400
})

} // Ende return
} // Ende Klasse

var oFenster = new kFenster();
oFenster.baueFenster.show();

It works fine.
I close the window !

Now when i type in the firebug console


var oFenster = new kFenster();
oFenster.baueFenster.show();

It works !
I think the problem from Test 1 is.
With window.close(); the window object is destroy.

Your sincerly

Stephan

BitPoet
29 Sep 2009, 7:50 AM
Or you configure your window with


closeAction: 'hide'

to reuse the existing instance and make Ext.getCmp work.

Viele Gre
-Chris