Google Captcha does not reload, 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 Submit button- Captcha should reload, but it never happens.
Here is my code
Maybe my logic is wrong? I can’t understand what I’m doing wrong here. Please help
(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 () {
var inputButton = $(this);
var inputForm = inputButton.parents('form');
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);