Skip to content

Instantly share code, notes, and snippets.

@achimoraites
Created July 27, 2020 20:42
Show Gist options
  • Save achimoraites/dad261a67ef15d6c1992e8d14eb79418 to your computer and use it in GitHub Desktop.
Save achimoraites/dad261a67ef15d6c1992e8d14eb79418 to your computer and use it in GitHub Desktop.
drag n drop for tables
let table = document.querySelector("tbody");
const _self = this;
// this way we avoid data binding
_self.dragNdrop = JSON.parse(JSON.stringify(_self.formItems));
Sortable.create(table, {
onEnd({
newIndex,
oldIndex
}) {
_self.dragNdrop.splice(
newIndex,
0,
..._self.dragNdrop.splice(oldIndex, 1)
);
console.log(_self.dragNdrop);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment