PDA

View Full Version : onRender question: when does it get called?



finkster
14 Mar 2010, 3:11 PM
Hi Everyone,

I'm trying to use the SuperField extension (http://www.extjs.com/forum/showthread.php?t=47533), but I'm having trouble getting it to work in Internet Explorer (works fine in FF).

After placing debug statements into the SuperField code, it looks like the root cause is that the extension's onRender method is not being called in IE.

I've read the docs on writing extensions, but I'm still not clear on when the onRender method actually get's called. Does it get called implicitly when some event is fired? It does not appear to be called explicitly in SuperField's code.

In SuperField's case, it appears that initComponent is called when the page is inititially loaded (in both FF and IE). When I explicitly call SuperField's setValue method to load it with data, the onRender method is called in FF, but not in IE. Does anyone know what could prevent IE from calling the onRender method?

Thanks.

Mike Robinson
15 Mar 2010, 6:32 AM
onRender will be called, but you do need to be aware that it might be called a few milliseconds "too soon" depending on your browser implementation.

ExtJS provides a "delay" option for event-handlers, which you should use. This delays the response to the event by a tiny amount, guaranteeing that any background-threads that your browser might use for rendering have actually had time to finish their work. (You can also use "single" here, since a render should only happen once.)

finkster
15 Mar 2010, 8:38 AM
Thanks for the response, but onRender is not being called in IE, and I'm trying to figure out why. It's not firing too soon. It's not firing at all.

Mike Robinson
15 Mar 2010, 8:57 AM
Hmm... I overlooked that you were talking about a third-party extension.

finkster
15 Mar 2010, 9:01 AM
Yes, that's where the issue seems to be. For some reason in that extension the onRender method doesn't fire in IE. I can't find any documentation that states when onRender is supposed to fire, or if there is a way to fire it explicitly.

finkster
15 Mar 2010, 12:10 PM
I solved the issue. The SuperField was contained in a minimized FieldSet, so at the time that I called setValue on it, it had not officially been rendered and hence the onRender method was not called. I set the config option 'forceLayout: true' on the containing FormPanel, and that fixed the problem. Seems simple now, but it took me forever to figure it out.