PDA

View Full Version : Simple Id problem



cabster
24 Aug 2009, 5:26 AM
Hello all,

i have a little problem.
I have a panel that i would like to disable if it exists.

panel:


messagePanel.add({
//body : allMessages,
//html : allMessages
items : [{html : allMessages, id : 'errorMessage'}]
});


When i try to destroy the panel with
Ext.getCmp("errorMessage").destroy(); the browser tells me that the Ext.getCmp("errorMessage") is undefined.

How can i check if the ID does exists?

thank you

SAnDAnGE
24 Aug 2009, 5:55 AM
if (Ext.getCmp('errorMessage') != undefined) {
Ext.getCmp("errorMessage").destroy();
}

cabster
26 Aug 2009, 5:18 AM
Thank you for the answer.

i tried




if (Ext.getCmp('errorMessage') != "undefined") {
Ext.getCmp("errorMessage").destroy();
}


I tried undifined with "" ("undefined") That didn't work.

undifined without "" won't work right? (i can't test at the moment)

Northrog
26 Aug 2009, 5:33 AM
Try typeof(Ext.getCmp('errorMeesage')) != "undefined"