SortableJS / vue.draggable.next

Vue 3 compatible drag-and-drop component based on Sortable.js
https://sortablejs.github.io/vue.draggable.next/#/simple
MIT License
3.91k stars 531 forks source link

How to pass the whole element object to the inner draggable #113

Closed Doogiemuc closed 2 years ago

Doogiemuc commented 2 years ago

How can I pass the whole element object into my draggable components.

The items that I want to drag are vue3-components. I can pass individual attributes of the current element. But how can I pass the whole element?

let proposalsInBallot = [
  { id: 4711, title: "Some title", ... },
  { id: 4712, title: "Another title", ... },
  { id: 4713, title: "And one more title", ... },
];

<draggable v-else
        id="myDraggable"
        v-model="proposalsInBallot"
        class="draggable"
        item-key="id"
        :disabled="loading || castVoteLoading"
        :swap-threshold="0.5"
        :delay="40"
        :animation="500"
        :can-scroll-x="false"
    >
        <template #item="{prop}">
            <law-panel
                ref="proposalInBallot"
                :law="prop"               // <======== how to do this???
                :read-only="true"
                :collapse="true"
            />
        </template>
    </draggable>

It looks like that undefined is passed.

I also tried :law="{prop}. Then an empty object is passed

How can I pass the whole "prop" object into my vue-component "law-panel"

Doogiemuc commented 2 years ago

Ok, I tried again and now I worked as shown in the code above. :law="prop". (no curly braces)