Sortable
Sortable copied to clipboard
how to implement modal user confirmation after drop?
Custom How to implement modal popup to confirm drop? Modal popup can have Yes/No button and question: Are you confirm draganddrop?
if user clicks No - element must be returned to his initial position if user clicks Yes - action is completed with element current position.
- Javascript: https://codesandbox.io/s/sortablejs-javascript-jy3tl?file=/src/index.js
onEnd: (evt) => {
if(confirm("Are you sure?")) {
/* normal ajax code to save the change */
} else {
if (evt.oldIndex >= evt.from.children.length) {
evt.from.appendChild(evt.item)
} else {
evt.from.insertBefore(evt.item, evt.from.children[evt.oldIndex])
}
}
}