On the legacy form there was an issue where the company selection dropdown stopped working if another gateway was selected within the form. The issue behind this was that every time the gateway was changed a new script was sent over which attached and additional listener for when the gateway changed. Since the gateway was never removed, every time the gateway changed another listener was attached and fired. This means the initialization for the DtD plugin was being called every time, which caused issues.
This pulls out the event listener into its own script so that it's only attached once per page, so it only fires one time. This resolved the overlying issue.
As a bonus, I also noticed that IDs were being used to select for input fields. This means that multiple legacy forms on a page could not use this add-on. I went ahead and changed the selector to a class (and tweaked the JS) so it's no longer an issue.
Affects
Legacy and multi-step forms using this add-on.
Pre-review Checklist
[x] Acceptance criteria satisfied and marked in related issue
[x] Relevant @since tags included in DocBlocks
[x] Changes logged to the Unreleased section of CHANGELOG.md
Resolves #11
Description
On the legacy form there was an issue where the company selection dropdown stopped working if another gateway was selected within the form. The issue behind this was that every time the gateway was changed a new script was sent over which attached and additional listener for when the gateway changed. Since the gateway was never removed, every time the gateway changed another listener was attached and fired. This means the initialization for the DtD plugin was being called every time, which caused issues.
This pulls out the event listener into its own script so that it's only attached once per page, so it only fires one time. This resolved the overlying issue.
As a bonus, I also noticed that IDs were being used to select for input fields. This means that multiple legacy forms on a page could not use this add-on. I went ahead and changed the selector to a class (and tweaked the JS) so it's no longer an issue.
Affects
Legacy and multi-step forms using this add-on.
Pre-review Checklist
@since
tags included in DocBlocksUnreleased
section ofCHANGELOG.md
Testing Instructions