X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/9135a85de4eef32a91c7a3ee0aa405ed454e5a4c..refs/pull/4978/head:/resources/js/components/add-remove-rows.js diff --git a/resources/js/components/add-remove-rows.js b/resources/js/components/add-remove-rows.js index 19d2249fb..3213c4835 100644 --- a/resources/js/components/add-remove-rows.js +++ b/resources/js/components/add-remove-rows.js @@ -1,6 +1,6 @@ -import {onChildEvent} from "../services/dom"; -import {uniqueId} from "../services/util"; -import {Component} from "./component"; +import {onChildEvent} from '../services/dom'; +import {uniqueId} from '../services/util'; +import {Component} from './component'; /** * AddRemoveRows @@ -8,6 +8,7 @@ import {Component} from "./component"; * Needs a model row to use when adding a new row. */ export class AddRemoveRows extends Component { + setup() { this.modelRow = this.$refs.model; this.addButton = this.$refs.add; @@ -19,7 +20,7 @@ export class AddRemoveRows extends Component { setupListeners() { this.addButton.addEventListener('click', this.add.bind(this)); - onChildEvent(this.$el, this.removeSelector, 'click', (e) => { + onChildEvent(this.$el, this.removeSelector, 'click', e => { const row = e.target.closest(this.rowSelector); row.remove(); }); @@ -44,9 +45,10 @@ export class AddRemoveRows extends Component { */ setClonedInputNames(clone) { const rowId = uniqueId(); - const randRowIdElems = clone.querySelectorAll(`[name*="randrowid"]`); + const randRowIdElems = clone.querySelectorAll('[name*="randrowid"]'); for (const elem of randRowIdElems) { elem.name = elem.name.split('randrowid').join(rowId); } } -} \ No newline at end of file + +}