Add buttons for toggle on and off
This commit is contained in:
@@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static classes = [ "toggle" ]
|
||||
static targets = [ "checkbox" ]
|
||||
|
||||
toggle() {
|
||||
this.element.classList.toggle(this.toggleClass)
|
||||
@@ -14,4 +15,16 @@ export default class extends Controller {
|
||||
remove() {
|
||||
this.element.classList.remove(this.toggleClass)
|
||||
}
|
||||
|
||||
checkAll() {
|
||||
this.checkboxTargets.forEach(checkbox => {
|
||||
checkbox.checked = true
|
||||
})
|
||||
}
|
||||
|
||||
checkNone() {
|
||||
this.checkboxTargets.forEach(checkbox => {
|
||||
checkbox.checked = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user