Rename select-all-controller

This commit is contained in:
Matt-Yorkley
2023-05-07 14:03:51 +01:00
parent fed7c3da51
commit c4bc0a7bbd
3 changed files with 23 additions and 23 deletions

View File

@@ -0,0 +1,19 @@
import { Controller } from "stimulus";
export default class extends Controller {
static targets = ["all", "checkbox"];
connect() {
this.toggleCheckbox()
}
toggleAll() {
this.checkboxTargets.forEach(checkbox => {
checkbox.checked = this.allTarget.checked;
});
}
toggleCheckbox() {
this.allTarget.checked = this.checkboxTargets.every(checkbox => checkbox.checked);
}
}