0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-07 17:40:57 +00:00
BookStackApp_BookStack/resources/assets/js/components/toggle-switch.js

18 lines
No EOL
420 B
JavaScript

class ToggleSwitch {
constructor(elem) {
this.elem = elem;
this.input = elem.querySelector('input[type=hidden]');
this.checkbox = elem.querySelector('input[type=checkbox]');
this.checkbox.addEventListener('change', this.stateChange.bind(this));
}
stateChange() {
this.input.value = (this.checkbox.checked ? 'true' : 'false');
}
}
export default ToggleSwitch;