Created
July 27, 2020 20:42
-
-
Save achimoraites/dad261a67ef15d6c1992e8d14eb79418 to your computer and use it in GitHub Desktop.
drag n drop for tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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