diff --git a/recaptcha.js b/recaptcha.js index 01f8b5a..220966f 100644 --- a/recaptcha.js +++ b/recaptcha.js @@ -1,6 +1,7 @@ (function ($, window, document) { Drupal.behaviors.recaptcha = { + widgets: {}, attach: function (context, settings) { // Check if the reCAPTCHA script is loaded yet. If not, don't worry: the // onload callback recaptchaOnLoad() will make sure that this function is @@ -9,7 +10,7 @@ return; } $('.g-recaptcha', context).once('drupal-recaptcha').each(function () { - grecaptcha.render(this, $(this).data()); + Drupal.behaviors.recaptcha.widgets[this.id] = grecaptcha.render(this, $(this).data()); }); } }; diff --git a/recaptcha.test b/recaptcha.test index f262a76..0d35de6 100644 --- a/recaptcha.test +++ b/recaptcha.test @@ -130,7 +130,7 @@ class ReCaptchaBasicTest extends DrupalWebTestCase { $captcha_sid = $this->getCaptchaSid(); $grecaptcha = '
'; $this->assertRaw($grecaptcha, '[testReCaptchaOnLoginForm]: reCAPTCHA is shown on form.' . $grecaptcha); - $this->assertRaw('', '[testReCaptchaOnLoginForm]: reCAPTCHA is shown on form.'); + $this->assertRaw('', '[testReCaptchaOnLoginForm]: reCAPTCHA API script is present.'); $this->assertNoRaw($grecaptcha . '