From 99b6e79ad29f263971f99e4b028832703ca68433 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 20 Oct 2023 18:48:02 +0100 Subject: [PATCH] Ensure newly created checkboxes are selected --- app/webpack/javascripts/modules/selectAll.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/webpack/javascripts/modules/selectAll.mjs b/app/webpack/javascripts/modules/selectAll.mjs index ffdb7574f3..e32591e80c 100644 --- a/app/webpack/javascripts/modules/selectAll.mjs +++ b/app/webpack/javascripts/modules/selectAll.mjs @@ -34,14 +34,14 @@ export class SelectAll { if (!this.$module) { return } const selector = this.$module.dataset.selectAllClass - const collection = this.$module.dataset.collectionClass + this.collection = this.$module.dataset.collectionClass this.selectAllBox = this.$module.querySelector(`.${selector}`) this.selectAllBox.addEventListener('change', () => this.toggleSelection()) - this.checkBoxes = document.querySelectorAll(`.${collection}`) } toggleSelection = () => { - this.checkBoxes.forEach((box) => { box.checked = this.selectAllBox.checked }) + const checkBoxes = document.querySelectorAll(`.${this.collection}`) + checkBoxes.forEach((box) => { box.checked = this.selectAllBox.checked }) } }