PDA

View Full Version : delayed evaluation?



don4321
20 Jul 2009, 10:18 AM
Here I have a big server side script, at the almost bottom part of it I have a condition evaluation line, if true, include a form element with id of "addMe2", which I'd like to auto populate data for selection. At the top of the script, I have a line that does the same condition evaluation, if true, run js script to get the data with Ext.data.Store

Now it's not working, that is, when the condition is true, the data from data.Store failed to be loaded into "addMe2". For the data.Store part, no problem, similar code works fine with another server side script.

What I suspected is, the first condition evaluation runs fast and didn't notice the existence of the "addMe2" DOM id, so, it aborted. Yes?

If I move the js code for the data.Store part to the bottom right after the condition evalaution then, the js code would be inside some HTML tr / td code etc.
I think I tried this like two days ago, didn't work neither. What gives?

Please let me know if the above is unclear about the problem.

Thanks.

mjlecomte
20 Jul 2009, 11:02 AM
Posting working code as a proof of concept would be much better to explain.

don4321
20 Jul 2009, 11:57 AM
I think I know the culprit now, that is, the inital load of the page with an Ext window load a URL dynamically, maybe Main server script or maybe Main2 server script, and yes it loads correctly. But the js/Ext scripts on the Main page has not been loaded/executed. Same behavior for both Firefox 3.5 and IE7. How to load the js/Ext scripts as well for the Main page?

I've tested loading the Main page directly, and that loads all the js/Ext scripts, got expected results...

Many thanks.

Additional Info:
The first load is an Ext window with autoLoad URL of (Main or Main2 server script) and the Main page itself loads two form.ComboBox, and default to show.

Sorry the code is pretty messy.

pmatsumura
20 Jul 2009, 11:59 AM
As MJ said, please post some sample code to work with.

Thanks,
Patrick

Lukman
20 Jul 2009, 5:52 PM
http://extjs.com/deploy/ext-3.0.0/docs/?class=Function&member=defer

don4321
20 Jul 2009, 6:37 PM
Lukman, should I still try the defer function after the additional info I just added? Thanks.

Condor
21 Jul 2009, 12:48 AM
You'll need to synchronize your request (issue the second request in the callback of the first one).

don4321
21 Jul 2009, 5:52 AM
Thanks, Condor, I tried to search for doc on how to use callback to no avail and some results of the forum search didn't help much neither. Could you offer a sample of how to use callback in this case?