Skip to content

Instantly share code, notes, and snippets.

@SilentKernel
Created January 16, 2023 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilentKernel/08e13da63d07e5fe2eebdcbd4b73a4f6 to your computer and use it in GitHub Desktop.
Save SilentKernel/08e13da63d07e5fe2eebdcbd4b73a4f6 to your computer and use it in GitHub Desktop.
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