Created
January 16, 2023 12:47
-
-
Save SilentKernel/08e13da63d07e5fe2eebdcbd4b73a4f6 to your computer and use it in GitHub Desktop.
Un controller Stimulus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Controller} from '@hotwired/stimulus' | |
/* stimulusFetch: 'lazy' */ | |
export default class extends Controller { | |
static values = { | |
class: String, | |
} | |
connect() { | |
this.checkBoxes = document.getElementsByClassName(this.classValue); | |
} | |
toggle(event) { | |
event.preventDefault(); | |
Array.from(this.checkBoxes).forEach((el) => { | |
el.checked = true; | |
}); | |
} | |
unToggle(event) { | |
event.preventDefault(); | |
Array.from(this.checkBoxes).forEach((el) => { | |
el.checked = false; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment