Hi all, I need to know if a boxComponent exists in a ext formPanel in order to take some actions... Is there some way to know that? something like this:
if(getElementById("boxId") != 'undefined' ){
alert('exists');
}
Hi all, I need to know if a boxComponent exists in a ext formPanel in order to take some actions... Is there some way to know that? something like this:
if(getElementById("boxId") != 'undefined' ){
alert('exists');
}
You can use Ext.get('boxId'). It returns null if the object doesn't exist and returns an Ext.Element object.
Using getElementById would probably be much faster though. Do you have any specific objection against it?
var boxComponent = formPanel.findById('boxId');
if(boxComponent != null) {
alert('exists');
}
I think use of Ext.get and Ext.getCmp is discouraged.
The common pattern that most people use is this:
var myBoxCmp = Ext.getCmp('cmpId');
if(myBoxCmp){
myBoxCmp.doSomething();
}
Same thing for Elements:
var el = Ext.get('elId');
if(el){
el.doSomething();
}
You can also use methods like Container.findById, but if you have an id (assuming it is unique, which it should be) just use getCmp.