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 }) } }