UndefinedOffset / silverstripe-nocaptcha

A spam protector and form field using Google's reCAPTCHA v2 or optionally a foundation v3 implementation
BSD 3-Clause "New" or "Revised" License
31 stars 37 forks source link

Cannot read property 'settings' of undefined - When in invisible mode #31

Open Codesesh opened 7 years ago

Codesesh commented 7 years ago

When using version 0.4.0 of this module & using the invisible mode we get:

            if(typeof jQuery!='undefined' && typeof jQuery.fn.validate!='undefined') {
                var formValidator=jQuery(form).data('validator');
                var superHandler=formValidator.settings.submitHandler; // error happening here
                formValidator.settings.submitHandler=function(form) {
                    grecaptcha.execute();
                };

https://www.dropbox.com/s/2f4qbfjjd2298f8/Screenshot%202017-06-07%2010.29.22.png?dl=0

https://www.dropbox.com/s/zohx305s4vowabz/Screenshot%202017-06-07%2010.29.47.png?dl=0

default_size: "invisible" - Doesn't work, throws error as above. default_size: "normal" - Works

Version 0.3.2 is working fine though.

I am using Silverstripe CMS/Framework 3.3.1

UndefinedOffset commented 7 years ago

The reason for it working fine in normal mode is because invisible requires more work on the JS end of things than normal does. Are you loading a custom version of jQuery validate (i.e. the one not included in the core)? Is your form build through userforms? or custom?

goldfinch commented 7 years ago

I think he has a custom one as I have,

I just fixed that by clearing default requirements, hope it helps

Requirements::clear(THIRDPARTY_DIR . "/jquery/jquery.js");
Requirements::clear("userforms/thirdparty/jquery-validate/jquery.validate.min.js");
Codesesh commented 7 years ago

I think there may of been a custom version of jQuery validate loaded.

I have just tried 0.4.0 of this module with SS 3.6.1 on a static contact form on another website and it is working fine.