0

Please help about the issue. I have onComplete on actionfunction called by button, and called function is another actionfunction that return PageReference for moving to next page.

When I click button at the first it doesn't move to next page, after then, I click it again, it works, moving to next Page. Why is this happening? Code below.

<script>
    function moveT(){
        movemove(
            document.getElementById("Name").value,
            document.getElementById("Email").value,
            document.getElementById("Phone").value,
            document.getElementById("Source").value,
        );
    }
</script>
<apex:form>

<Button class="col-mx-6  col-md-6" onclick="moveT()">Go to Next Page</Button>

<apex:actionFunction name="movemove" action="{!saveParams}" reRender="panel" oncomplete="moveToNext()">
    <apex:param name="Param1" assignTo="{!Param1}" value=""/>
    <apex:param name="Param2" assignTo="{!Param2}" value=""/>
    <apex:param name="Param3" assignTo="{!Param3}" value=""/>
    <apex:param name="Param4" assignTo="{!Param4}" value=""/>
</apex:actionFunction>
<apex:actionFunction name="moveToPrevious" action="{!moveTo0}"/>
<apex:actionFunction name="moveToNext" action="{!moveTo2}"/>

</apex:form>

public void saveParams(){
    // some data modification
    // No Page related action.
}

public PageReference moveTo2(){
        PageReference pg;
        pg = Page.VFPage2;

        return pg;
}

Thanks in advance!

  • Where have you define moveT() method invoked in onclick? – Reshma Dec 13 '18 at 8:45
  • @Reshma Oops, sorry. I edited it – YoungHoon Kim Dec 13 '18 at 8:59
  • @Reshma, All 4params are stored in Controller value as expected. just page moving is the problem. – YoungHoon Kim Dec 13 '18 at 9:01
0

A button causes a form submit. You need to cancel that the default behavior, so that it doesn't happen:

<button class="col-mx-6  col-md-6" onclick="moveT(); return false;">Go to Next Page</button>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.