View Full Version : el is undefined (the solution)

9 Feb 2010, 7:32 AM
Hi all,

basically this thread is not intended to ask for help but to provide some. I've been blocked by a problem that calls : el is undefined. I've read a lot of post on the subject. jsakalos told the answer. Your component(s) should be rendered.

For programmers : make sure that your component is DISPLAYED before you call some methods that require an update. To know if it require an update, you'll get the error el is undefined and the debbuger will point you in "refresh" method at this line : "el.update("");".
In my case, I juste called the myWindow.show(); method before setting my data with listView.bindStore();

For Extjs team, may I suggest that you look at the call order to update :). Maybe it does not need to refresh when it's not visible? This will make your librarie more "secure" in a certain matter. BTW, it's not a complain, it's a "you'll have less thread on the subject if you do this "fix" ".

Thanks :)

Mike Robinson
9 Feb 2010, 8:22 AM
The way that I understand it, messages like these occur when (and because) the object is not yet rendered. That is to say, no DOM elements are yet associated with it.

My experience also has been that, when you are listening for the render event, you should specify that you want it to fire after a few milliseconds' delay. Depending on the browser, the computer, and the phase of the moon8-|, the rendering otherwise might not actually be completely finished at the precise moment that the event handler runs.

A more robust solution to your problem might employ event-listeners in this way. I've seen some truly frightening ;) code in some Extensions which use "task runners" and other bits of Wonderous Magickal Thinges Not Meante For Ye Mortales....

9 Feb 2010, 11:17 AM

Yes, a lot of ppl solve this specific issues by using a listener such as : 'afterrender', when they have this message. But, in certain circomstances, you want to acquire the data before, validate it, and if ok, render the window.

My problem was : I was getting the data, after I was adding the data to the list and finally displaying the window. Which don't work. It's not clear that having the component visible before setting it's data is a requirements.

My solution was : Simply ask the window to display before setting the data.

My final point was : :) Maybe just have a "if" (or anything that fits for this) that check if it "can" refresh the component when data change. It's certainly not an issue, but, maybe a good "avoid errors and useless threads" feature :).