SortableJS / vue.draggable.next

Vue 3 compatible drag-and-drop component based on Sortable.js

Home Page:https://sortablejs.github.io/vue.draggable.next/#/simple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Help] Get parent element during onMove event

bpolaszek opened this issue Β· comments

Hey there,

From what I understood you can prevent a move to occur by setting the move prop with a function: if it returns false, the drag&drop won't happen. Cool! πŸ™‚

I'm just struggling to figure out how to retrieve the parent element the dragged element is getting dropped to.

Consider the following structure:

[
  {
    name: 'foo',
    children: [],
    childrenAllowed: true,
  },
  {
    name: 'bar',
    children: [],
    childrenAllowed: false,
  },
  {
    name: 'baz',
    children: [],
    childrenAllowed: true,
  },
]

As you probably guessed, I want to be able to move baz as a child of foo but not as a child of bar.
So I'm implementing an handleMove function which is supposed to return false whenever the element its getting moved to has childrenAllowed set to false, but I actually didn't figure out how to get that parent element within the move event...

Any ideas?
Thanks! πŸ™
Ben