Support

Account

Home Forums Front-end Issues Gravity Form AJAX Reply To: Gravity Form AJAX

  • Hi there,

    This is a classic conflict between Gravity Forms’ AJAX processing and your theme’s or another plugin’s JavaScript. When the shortcode is in the flexible content field, it’s likely being loaded dynamically after the initial page render, which can break Gravity Forms’ JavaScript initialization.

    Here are the most effective troubleshooting steps to resolve this:

    1. The jQuery Re-Trigger Method (Most Common Fix)
    Gravity Forms relies on jQuery events that fire on page load. Since your flexible content field loads after this, you need to manually re-trigger GF’s initialization. Add this to your theme’s functions.php or a custom plugin:

    php
    add_action( ‘wp_footer’, ‘reinitialize_gravity_forms’, 99 );
    function reinitialize_gravity_forms() {
    if ( ! is_admin() ) {
    ?>
    <script type=”text/javascript”>
    jQuery(document).ready(function($) {
    // Re-initialize Gravity Forms conditional logic
    if (typeof window[‘gform’] !== ‘undefined’) {
    gform.initCondLogic();
    }

    // Re-bind Gravity Forms AJAX events
    if (typeof window[‘gformInitPriceFields’] !== ‘undefined’) {
    gformInitPriceFields();
    }
    });
    </script>
    <?php
    }
    }
    2. Check for JavaScript Conflicts
    Temporarily switch to a default WordPress theme (like Twenty Twenty-Four) and disable all other plugins except Gravity Forms and ACF. If the AJAX works, you’ve confirmed it’s a conflict. Re-enable elements one by one to identify the culprit.

    3. Gravity Forms-Specific Solution
    In your form settings, try disabling AJAX temporarily to see if the conditional logic still works without the scrolling issue. If it does, the problem is definitely with the AJAX re-initialization.

    4. DOMContentLoaded Alternative
    Sometimes wrapping the re-initialization in a DOMContentLoaded event helps:

    javascript
    document.addEventListener(‘DOMContentLoaded’, function() {
    if (typeof window[‘gform’] !== ‘undefined’) {
    gform.initCondLogic();
    gform.initializeOnLoaded();
    }
    });
    The key is ensuring Gravity Forms’ JavaScript re-initializes after your flexible content field fully loads into the DOM. The jQuery method above typically resolves this in about 80% of similar cases I’ve encountered.

    Let us know which approach works for your setup!