X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/07b889547d28e68e5fc8f923c166bd607da17ad7..refs/pull/1554/head:/resources/assets/js/components/toggle-switch.js diff --git a/resources/assets/js/components/toggle-switch.js b/resources/assets/js/components/toggle-switch.js index 3be67d5dc..3dd1ce85c 100644 --- a/resources/assets/js/components/toggle-switch.js +++ b/resources/assets/js/components/toggle-switch.js @@ -6,12 +6,11 @@ class ToggleSwitch { this.input = elem.querySelector('input[type=hidden]'); this.checkbox = elem.querySelector('input[type=checkbox]'); - this.checkbox.addEventListener('change', this.onClick.bind(this)); + this.checkbox.addEventListener('change', this.stateChange.bind(this)); } - onClick(event) { - let checked = this.checkbox.checked; - this.input.value = checked ? 'true' : 'false'; + stateChange() { + this.input.value = (this.checkbox.checked ? 'true' : 'false'); } }