1

The action part of my button stops working as soon as I change my button to return my javascript confirmation.

Javascript:

function confirmDialog()
{
    var confirmation = confirm('Once you submit this record for approval, you might not be able to edit it or recall it from the approval process depending on your settings. Continue?');
    return confirmation;
}

Not working VF:

<apex:commandButton title="Submit this rebate for approval" value="Submit Rebate for Approval" action="{!submitForApproval}" rendered="{!!renderCloseButton}" rerender="forecastSection, rebateMessages, fullBlock" onclick="return confirmDialog();" />

Working VF:

<apex:commandButton title="Submit this rebate for approval" value="Submit Rebate for Approval" action="{!submitForApproval}" rendered="{!!renderCloseButton}" rerender="forecastSection, rebateMessages, fullBlock" onclick="confirmDialog();" />

The only difference in the working/non-working is returning the onclick. I want my action to only fire if my confirmation returns true. The second set calls the action method but regardless of their response on the confirmation dialog. I have another button with the exact same setup, but it works as I expect. What could I be doing wrong?

1 Answer 1

1

Turns out that I could not have a rerender when returning the 'onclick'. I had to work around this. The new pieces:

New Action Function:

<apex:actionFunction name="approvalJS" action="{!submitForApproval}" rerender="forecastSection, rebateMessages, fullBlock" />

New outputPanel for rerendering (This is required to prevent the entire page from refreshing on my button press):

<apex:outputPanel id="pointlessRerender" />

Updated confirmDialog:

function confirmDialog()
{
    var confirmation = confirm('Once you submit this record for approval, you might not be able to edit it or recall it from the approval process depending on your settings. Continue?');

    if (confirmation)
    {
        approvalJS();
    }
}

Updated button:

<apex:commandButton title="Submit this rebate for approval" value="Submit Rebate for Approval"  rendered="{!!renderCloseButton}" onclick="confirmDialog();" reRender="pointlessRerender" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .