mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Revert "Delegate events to the parent element"
This reverts commit e31c16df43.
This commit is contained in:
@@ -7,7 +7,11 @@ export default class extends Controller {
|
||||
connect() {
|
||||
this.toggleCheckbox();
|
||||
|
||||
this.element.addEventListener("change", this.#toggleChangeListener.bind(this), {passive: true});
|
||||
this.allTarget.addEventListener("change", this.toggleAll.bind(this));
|
||||
|
||||
this.checkboxTargets.forEach((checkbox) => {
|
||||
checkbox.addEventListener("change", this.toggleCheckbox.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
toggleAll() {
|
||||
@@ -35,15 +39,6 @@ export default class extends Controller {
|
||||
|
||||
// private
|
||||
|
||||
// Delegate events for targets (this ensures we catch events from newly-added elements after an ajax action)
|
||||
#toggleChangeListener(event) {
|
||||
if (event.target == this.allTarget) {
|
||||
this.toggleAll();
|
||||
} else if (this.checkboxTargets.includes(event.target)) {
|
||||
this.toggleCheckbox();
|
||||
}
|
||||
}
|
||||
|
||||
#checkedCount() {
|
||||
return this.checkboxTargets.filter((checkbox) => checkbox.checked).length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user