mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Use requestSubmit() method for actually submit the form with event
... that could be catch by turbo (and then handled by cable_ready) `this.catchFormSubmit` avoid infinite loop then
This commit is contained in:
@@ -15,6 +15,7 @@ export default class extends Controller {
|
||||
|
||||
initialize() {
|
||||
this.parentForm = this.pmIdTarget.form;
|
||||
this.catchFormSubmit = true;
|
||||
|
||||
// Initialize Stripe JS
|
||||
this.stripe = Stripe(this.data.get("key"));
|
||||
@@ -40,7 +41,7 @@ export default class extends Controller {
|
||||
// Before the form is submitted we send the card details directly to Stripe (via StripeJS),
|
||||
// and receive a token which represents the card object, and add that token into the form.
|
||||
stripeSubmit = (event) => {
|
||||
if(!this.stripeSelected()) { return }
|
||||
if(!this.stripeSelected() || !this.catchFormSubmit) { return }
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
@@ -54,8 +55,8 @@ export default class extends Controller {
|
||||
this.expYearTarget.setAttribute("value", response.paymentMethod.card.exp_year);
|
||||
this.brandTarget.setAttribute("value", response.paymentMethod.card.brand);
|
||||
this.last4Target.setAttribute("value", response.paymentMethod.card.last4);
|
||||
|
||||
this.parentForm.submit();
|
||||
this.catchFormSubmit = false;
|
||||
this.parentForm.requestSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user