]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/toggle-switch.js
Updated another set of components
[bookstack] / resources / js / components / toggle-switch.js
index b9b96afc5d07728d992e9cd49eab9e29a6df1f2a..b749eb54132492efa06b53a05a151fe35c282c3c 100644 (file)
@@ -1,10 +1,10 @@
+import {Component} from "./component";
 
-class ToggleSwitch {
+export class ToggleSwitch extends Component {
 
-    constructor(elem) {
-        this.elem = elem;
-        this.input = elem.querySelector('input[type=hidden]');
-        this.checkbox = elem.querySelector('input[type=checkbox]');
+    setup() {
+        this.input = this.$el.querySelector('input[type=hidden]');
+        this.checkbox = this.$el.querySelector('input[type=checkbox]');
 
         this.checkbox.addEventListener('change', this.stateChange.bind(this));
     }
@@ -18,6 +18,4 @@ class ToggleSwitch {
         this.input.dispatchEvent(changeEvent);
     }
 
-}
-
-export default ToggleSwitch;
\ No newline at end of file
+}
\ No newline at end of file