Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

how to implement modal user confirmation after drop?

Open oleg-moseyko opened this issue 2 years ago • 1 comments

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

oleg-moseyko avatar Aug 25 '23 08:08 oleg-moseyko

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])
    }
  }
}

frenkel avatar Aug 22 '24 09:08 frenkel