X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/3286f29a61833327b5701b28db626d0a480b07f9..refs/pull/1534/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'); } }