I have a popup window (selectReasonCode) that is opened up from a button. The button has the following code
var selectReasonCode:SelectReasonCode = new SelectReasonCode();
selectReasonCode.title = "Reason Codes";
selectReasonCode.showCloseButton = true;
PopUpManager.addPopUp(selectReasonCode, this, true);
PopUpManager.centerPopUp(selectReasonCode);
selectReasonCode.updateReasons(reasonTypeId, rasonCds); //This sets the dataprovider
on the select reason code screen I have a data grid that is populated with the values that is set in the updateReasons method (which is called by the method above.
The thing is that my popup screen opens up empty. But if I add a break point in the code in debug mode and pass it the screen opens up with data. I believe that the screen opens up before the data actually gets set. Can this be true? And if so how can I assure that the update Reasons method gets executed first before the screen opens up?
To exclude debug mode… I added a line after the updateReasons code to cause an error. Hence the error display first, the user clicks ok and then opens the popup. The data display then in the popup.
Yes!
Execute the method and don’t display the pop up until after you get data back. Executing in debug mode could give you the pause you need while waiting for data to return from the remote server; depending where the debug point is.
But, you can just move the updateReasons method call like this:
However, under the assumption that updateReasons fires off a asynchronous service call, you’ll have to wait until the data is returned before showing the popup. Conceptually like this: