Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Google Captcha does not load in WP Gravity Forms

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #260104
    rolandas
    Participant

    Anyone has experience with WP Gravity Forms?

    Google Captcha does not load, I can’t figure out why..

    First I load it on link click- it opens modal and loads Captcha- everything is ok here, but when I click on Form’s Sumbit button- Captcha should reload, but it never happens. here is my code :)

    (function ($) {
    
    'use strict';
    
    $(window).load(function () {
    
        if ($('body').hasClass('page-id-97')){
    
            //THIS WORKS OK
    
            $('.manual-download-link').on('click', function () {
    
                var thisButtonData = $(this).data('popup');
    
                var popUpContainer = $('#popmake-'+thisButtonData);
    
                popUpContainer.find('.g-recaptcha').each(function (index, element) {
    
                    // Ensure field is empty before rendering CAPTCHA
                    if ($(this).is(':empty')) {
                        // Site key
                        var site_key = $(this).attr('data-sitekey');
                        // CAPTCHA theme
                        var theme = $(this).attr('data-theme');
                        // Native DOM element
                        var element = $(this).get(0);
                        // Render CAPTCHA
                        grecaptcha.render(element, {'sitekey': site_key, 'theme': theme});
                    }
                });
    
            });
    
            $('div.gform_footer input').on('click', function () {
    
                $(document).bind('gform_post_render', function () {
    
                    inputForm.each(function (index, element) {
    
                        var n = $(this).find('.g-recaptcha');
    
                        //THIS DOES NOT LOAD CAPCTHA- WHY?! ;(
    
                        // Ensure field is empty before rendering CAPTCHA
                        if (n.is(':empty')) {
                            // Site key♂
                            var site_key = n.attr('data-sitekey');
                            // CAPTCHA theme
                            var theme = n.attr('data-theme');
                            // Native DOM elemento
                            // var element = $(this).get(0);
                            var element = n.get(0);
                            // Render CAPTCHA
                            grecaptcha.render(
                                element, {
                                    'sitekey': site_key,
                                    'theme': theme
                                }
                            );
                        }
                    });
                });
            })
        }
    });
    })(jQuery);
    
    
Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.