PDA

View Full Version : Ext.getCmp() sometimes returns 'undefined' in Google Chrome



poulet1212
21 Sep 2010, 1:43 AM
Hi all,

I use Ext 3.2.1. My application runs well with FF but in Chrome, when I load the page, I sometimes have errors because Ext.getCmp('mycomp') is null. I said sometimes because if I reload many times, then it goes... Isn't it weird??

Well here an example of how I use getCmp.

firstfile.js:
Ext.onReady(function() {
var _myGrid= new Ext.grid.GridPanel({
id:'JobGrid',
...
});
});

secondFile.js
Ext.onReady(function() {

//Fails with chrome, Ext.getCmp('JobGrid') is null here
Ext.getCmp('JobGrid').store.on('load', function() {
...
});
});


I need to access the store of the JobGrid defined in the first file. Do I get it the good way? Someone knows why it fails on Chrome.

regards,
Rémy

Animal
21 Sep 2010, 1:51 AM
Timing.

Why would you wait till onReady just to create a GridPanel?

I mean you must wait to RENDER it, but go ahead and create it, otherwise your other modules won't see it.

And think about your app structure. Do not use Ext.getCmp. If the grid is part of your app, make it part of your app's namespace.

poulet1212
21 Sep 2010, 6:43 AM
Ok. I will make my grid part of the namespace so I can access it from the others modules.

thank you for the input :)