diff --git a/assets/js/app.js b/assets/js/app.js index 4cdc29e..cc5115c 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,5 +1,5 @@ import '../css/app.css'; import * as Highcharts from "highcharts"; -import {draggable} from './draggable'; +import './draggable'; global.Highcharts = Highcharts; diff --git a/assets/js/draggable.ts b/assets/js/draggable.ts index 61a1cad..4d37a6c 100644 --- a/assets/js/draggable.ts +++ b/assets/js/draggable.ts @@ -7,16 +7,18 @@ const sortable = new Sortable(document.querySelectorAll('.draggable_container'), draggable: '.draggable' }); -sortable.on('sortable:stop', (event) => { - const draggedInputs = document.querySelectorAll('.draggable_container .draggable input'); - draggedInputs.forEach((input: Element, index: number) => { - if (input.hasAttribute('name')) { - let name = input.getAttribute('name') || ''; - if (!name.match(/\[\d+]/)) { - // No DOM modification if attribute was removed already. - return; +sortable.on('sortable:stop', () => { + document + .querySelectorAll('.draggable_container .draggable input') + .forEach((input: Element, index: number) => { + if (input.hasAttribute('name')) { + let name = input.getAttribute('name') || ''; + if (!name.match(/\[\d+]/)) { + // No DOM modification if attribute was already removed. + return; + } + input.setAttribute('name', name.replace(/\[\d+]/g, '['+index+']')); } - input.setAttribute('name', name.replace(/\[\d+]/g, '['+index+']')); - } - }); + }) + ; });