You need to sign in to do that
Don't have an account?
Call JavaScript after action executes
Hello,
I have a VF page as follows. Included here are snippets of code:
//Command button that whose click event invokes an action that calls a webservice and creates a Result object
<apex:commandButton id="commandButton1" value="PL">
<apex:actionSupport event="onclick" action="{!doPLSearch}" onsubmit="openPopup()" reRender="pageBlockSection1"/>
</apex:commandButton >
//hidden field to store Id of the newly created Result object
<apex:inputhidden id="resId" value="{!resultIdAfterPLCall}" />
//JS to open result display VF page.
<script>
var newWin=null;
function openPopup(){
var resultId = document.getElementById("{!$Component.resId}");
var url="/apex/PLResultDisplay"+"?id="+resultId ;
newWin=window.open(url, 'Popup','height=500,width=400,left=100,top=100,resizable=no,scrollbars=yes,toolbar=yes,status=no');
if (window.focus)
{
newWin.focus();
}
return false;
}
</script>
The doPLSearch() calls a webservice and stores the ID of the newly created Result object in 'resultIdAfterPLCall'.
How can I ensure that the JavaScript gets called only after the doPLSearch() completes?
Currently, it displays the 'PLResultDisplay VF page without any data as the Javascript executes before doPLSearch() is complete and 'resultIdAfterPLCall' is null.
Thanks.
Try the "oncomplete" attribute. By the way, you don't need the actionsupport component here. Just move those attributes to the commandButton (excluding "event", of course).
All Answers
Try the "oncomplete" attribute. By the way, you don't need the actionsupport component here. Just move those attributes to the commandButton (excluding "event", of course).
Thanks for your help.