Closed AMHVerse closed 4 years ago
same issue
Same here! There seems to a confusion when there more than two forms in the same page. The plugin seems to try to automatically submit the wrong form.
Yup, would be great to get a fix out for this issue
i've changed it to use $form.trigger('submit'), i've tested with multiple forms on the page and its working fine for me. Please let me know if you're still having issues.
fixed in 2.3.0
@samuelbirch I'm sorry but I'm still having problems. On my code (and the demo templates of Craft), the $form
variable is an array containing one element. The form element in that array is the correct one but calling $form.trigger("submit");
doesn't seem to trigger the submission whereas $form[0].submit();
does.
what version of jQuery are you using?
@samuelbirch I'm using jQuery 3.4.1
Craft demo shop. Jquery 2.1.4
If you are using the default templates it looks like this be of javascript code is blocking the form from submitting:
` $('#paymentForm').on('submit', function (ev) { $form = $(this);
if ($form.data('processing')) {
ev.preventDefault();
return false;
}
$form.data('processing', true);
});`
removing this will make it work.
the reason being, this snippet of code only allows the form to be submitted once, but in the case of braintree we submit the form first and block it in order to get the nonce and add it to the hidden input, we then unblock the form and submit it again, this time allowing it to post to the controller.
We placed the code into our payment form and doesn't get to the thank you page in Chrome.
Looked into it and In vendor/kuriousagency/commerce-braintree/src/assetbundles/dropinui/dist/js/DropinUi.js on line 157 It uses jQuery to submit the form, this doesn't always work.
Changing this to $form[0].submit(); works for us