Skip to content

Instantly share code, notes, and snippets.

@SilentKernel
Created January 16, 2023 12:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Un controller Stimulus
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