3

I've looked all over for this and haven't found anything, apologies if I missed it somewhere.

I am trying to set a variable in the controller to equal the response from the confirm and then proceed with the save action regardless of the response. The save action will then alter its behavior based on the response to the confirm.

My problem is that the action (save) never runs after the confirm answer is received. If I get rid of onclick and add the action back to the command button (and remove the actionFunction), it works as expected.

edit: myControllerBoolean is set to False as the default

Visualforce:

<apex:actionFunction name="doSave" action="{!save}">
    <apex:param name="param" assignTo="{!myControllerBoolean}" value=""/>
</apex:actionFunction>
<apex:commandButton value="Save" onclick="confirmThis();"/>

JS:

function confirmThis() {
    var answer = confirm('True or False?');
    doSave(answer);
}

Thanks for any help you can provide!

2
<apex:actionFunction name="doSave" action="{!save}" rerender="none">
    <apex:param name="param" assignTo="{!myControllerBoolean}" value=""/>
</apex:actionFunction>
<apex:commandButton value="Save" onclick="confirmThis();" rerender="none"/>

Use rerender attribute with commandbutton and actionfunction.

| improve this answer | |
  • @mplax I don't think it will take any other action. – Tushar Sharma Sep 13 '16 at 18:06
  • I had to delete my comment - apparently, I did need both rerender="none" for the param to take the passed value. But now it isn't opening the PDF output whereas it did without the rerender="none" on the actionFunction. So I will need to look into that. Fixing one issue causes another... A sign that I'm a truly top notch programmer :-p – mplax Sep 13 '16 at 18:48

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.