Payment elements on ajax enabled forms do not appear after going 'back'

Created on 8 September 2025, about 2 months ago

Problem/Motivation

This module purports to support webforms that are ajax enabled.

This does mostly work, but if you go back to a previous page and re-view the payment element it does not work.

Steps to reproduce

If you add this element to a webform, and enable the webform for ajax, use multiple pages in the webform to create at least 2 pages, and then place this component on the second page.

View the form, complete the first page, view the second page, and then go back to the first page and then forward to the second page.

The payment element does not re-appear, and it's not possible to submit the form.

This is because the JavaScript that's added has a global variable: initStripeHasRun and it checks to see if it's set this variable before, and if it has, it aborts and does nothing.

Proposed resolution

Instead of checking a global variable then maybe this module should check something on the form or the stripe form element itself, so that if the component is added, removed and then comes back, it can be initialised.

Maybe for a more fully-featured solution the code should also 'detach' as well as 'attach' at the right points.

Remaining tasks

Code up a fix, and review it.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom steven jones

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024