mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Handle when input is already checked
ie. user hasn't click on anything
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
import { Controller } from "stimulus";
|
||||
export default class extends Controller {
|
||||
static targets = ["paymentMethod"];
|
||||
static targets = ["input"];
|
||||
|
||||
connect() {
|
||||
this.inputTargets.forEach((i) => {
|
||||
if (i.checked) {
|
||||
this.doSelectPaymentMethod(i.dataset.paymentmethodId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
selectPaymentMethod(event) {
|
||||
const paymentMethodContainerId = event.target.dataset.paymentmethodId;
|
||||
this.doSelectPaymentMethod(event.target.dataset.paymentmethodId);
|
||||
}
|
||||
|
||||
doSelectPaymentMethod(paymentMethodContainerId) {
|
||||
Array.from(
|
||||
document.getElementsByClassName("paymentmethod-container")
|
||||
).forEach((e) => {
|
||||
|
||||
Reference in New Issue
Block a user