]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/submit-on-change.js
Covered app icon setting with testing
[bookstack] / resources / js / components / submit-on-change.js
index 97996724235efda29fa1bc67752844da199cf644..da4ac699608f21a11a5392dfd272a3492ae178a9 100644 (file)
@@ -1,12 +1,20 @@
+import {Component} from "./component";
+
 /**
  * Submit on change
  * Simply submits a parent form when this input is changed.
- * @extends {Component}
  */
-class SubmitOnChange {
+export class SubmitOnChange extends Component {
 
     setup() {
-        this.$el.addEventListener('change', () => {
+        this.filter = this.$opts.filter;
+
+        this.$el.addEventListener('change', (event) => {
+
+            if (this.filter && !event.target.matches(this.filter)) {
+                return;
+            }
+
             const form = this.$el.closest('form');
             if (form) {
                 form.submit();
@@ -14,6 +22,4 @@ class SubmitOnChange {
         });
     }
 
-}
-
-export default SubmitOnChange;
\ No newline at end of file
+}
\ No newline at end of file