0

Here is the relevant vf markup. I am adding the actionfunction next to the button that I want to call it for. I've also put the action function at the very start of my form and end of the form to ensure that is it not the order of the script:

<apex:form id="dealForm" styleClass="deal-form">
    <!-- some other markup -->

    <div class="slds-grid slds-p-around--medium" id="add-component-btns-container">
        <div class="slds-col">
            <h2 class="slds-text-heading--medium slds-p-bottom--x-small">Add Opportunities</h2>

            <button id="show-digital-form-btn" type="button" class="slds-button slds-button--brand add-component slds-icon-custom-custom27">Digital</button>
            <apex:actionFunction name="prepDigitalForm" action="{!prepDigitalForm}" rerender="digitalForm" oncomplete="afterPrepDigitalForm()"/>

            <button id="show-print-form-btn" type="button" class="slds-button slds-button--brand add-component slds-icon-custom-custom55">Print</button>
        </div>
    </div>

    <!-- more markup -->
</apex:form>

I have jquery on the page and within my js file I have:

var dealSLDS = {
    // a bunch of other functions...

    bindButtons: function() {

        $('#show-digital-form-btn').on('click', function() {
            prepDigitalForm(); // actionFunction
        });

    },

    // other functions
}

$(document).ready(
    dealSLDS.bindButtons();

});

The oncomplete javascript actually runs. However, the actual actionfunction does not seem to be executing. I threw an exception as the first line in the method and it still came back just fine. No system.debug messages are in the log either. Any ideas?

1 Answer 1

2

I tried the code you posted and it worked for me. I made 1 change to it. the code you posted for ready below did not have the anonymous function declaration

$(document).ready(function() {
    dealSLDS.bindButtons();
    alert('Hellofrom');

});

I am also assuming the form id you are re-rendering 'digitalForm' is part of your VF markup

One of the other things to check is to put a apex:pageMessages to see if there is any error in the page which is stopping the page from re-rendering.

<apex:pageMessages id="errors" />

<apex:actionFunction name="prepDigitalForm" action="{!prepDigitalForm}" rerender="digitalForm,errors" oncomplete="afterPrepDigitalForm()"/>

I just put a simple system.debug in the server side controller method and it worked fine for me.

1
  • 1
    Thanks RedDevil. There was a hidden error message "id must be 15 characters". It had to do with a selectList that I had further down the page that referenced an id field. For some reason, it was requiring a value in that field during the re-render. My guess is because it is required at the object level.
    – willard
    Jun 20, 2017 at 2:37

You must log in to answer this question.

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