Reputation: 1407
I have below code which is defined inside a function which actually set width of parent component and do layout...this function is called from 4 places and at one place there is scenario that below error comes, you can see i have checked for undefined but still it is going inside this IF and i get error :( please help identify issue
Ext Js 3.4.2
ERROR
Uncaught TypeError: Cannot read property 'getWidth' of undefined
CODE
if((typeof Ext.getCmp("cmp1") !== 'undefined') && (typeof Ext.getCmp("cmp2") !== 'undefined')){
Ext.getCmp("cmp1").setWidth(Ext.getCmp("cmp2").getWidth()-2);
Ext.getCmp("cmp1").doLayout();
}else{
//Call self again in 3 sec once render
//setTimeout("doLayoutofcustomPanel()", 3000);
}
Upvotes: 0
Views: 3118
Reputation: 1407
I able to figure out issue actually component was created but element (EL) was not present initially so it able to cross my IF check I need to put check as below to ensure element is present for which I need to fetch width. This worked fine
typeof Ext.getCmp("cmp2").el !== 'undefined'
I am using ExtJs 3.4.2
Upvotes: 2