Summary:
Support for ajax submit for reCaptcha invisible
Detailed Description:
Would it be possible to modify reCaptcha invisible implementation to support
optional ajax submission of forms.
I could do this with the other captchas but not reCaptcha invisible. There could
be an alternative solution but I couldn't find it.
The issue is that currently the form is submitted by default.
A mod to /plugins/recaptcha_invisible/cm_plugin.recaptcha_invisible.php, approx
line 127:
change:
\'callback\': function (recaptchaToken)
{
//HTMLFormElement.prototype.submit.call(frm);
}';
to:
\'callback\': function (recaptchaToken) {
var event = document.createEvent(\'Event\');
event.initEvent(\'captchacallback\', true, true);
var defaultSubmit = frm.dispatchEvent(event);
if (defaultSubmit) {
HTMLFormElement.prototype.submit.call(frm);
}
}';
FYI: just then needed to add the following into the js actions (uses jQuery Form
Plugin):
$(this).on('captchacallback', function(event) {
event.preventDefault(); // prevent default submit
var options = {
target: '#ajax-form-wrapper',
url: $(this).attr('action')+'?showtemplate=false',
type: 'post'
};
$(this).addClass('loading').ajaxSubmit(options);
});
Chris :)