Cascading Select List updated by Javascript
Using APEX 4.1.0.00.32
I have a form with 3 cascading select lists, each dependent on the list before:
BP_1, BP_2, and BP_3
I also have an external HTML element which can set BP_1, BP_2, and BP_3 with the correct values using Javascript (basically, the java script passes a ":" separated list which is parsed apart to set each of the values).
After setting BP1, I trigger a "$('#P47_BP_2').trigger('apexrefresh');" to refresh the select list for BP_2. Then I set BP_2 to the correct value, execute a "$('#P47_BP_3').trigger('apexrefresh');" and move onto BP_3.
So far, so good.
If I put "alert" statements within my code, I can actually see all of the BP_1, BP_2, and BP_3 lists get set to the correct values and the select lists display the correct entries.
HOWEVER...
Once I take the "alert" statements out, the second and third select lists get their updates but the displayed item is the first item in the list. I put the alert back in and everything is happy.
It almost appears that the apexrefresh takes longer than the javascript and so the values aren't loaded correctly.
For example:
BP_1 is ARMS, LEGS
When ARMS is selected:
BP_2 is UPPERARM, ELBOW, LOWERARM, WRIST, HAND
When HAND is selected
BP_3 is THUMB, INDEX, MIDDLE, RING, PINKIE
When the javascript executes without the sleep statement to set ARM:HAND:PINKIE:
BP_1 is ARMS, BP_2 is UPPERARM, BP_3 is null (because PINKIE is not a sub set of UPPERARM).
Is there a better way to do this?
Thank you in advance...
Edited by: SleepDeprivedInSeattle on Sep 20, 2012 10:47 AM