<template>
<div class="row">
<div class="col-3">
<h3>Draggable 1</h3>
<draggable class="list-group" :list="list1" group="people" @change="log">
<div
class="list-group-item"
v-for="(element, index) in list1"
:key="element.name"
>
{{ element.name }} {{ index }}
</div>
</draggable>
</div>
<div class="col-3">
<h3>Draggable 2</h3>
<draggable class="list-group" :list="list2" group="people" @change="log">
<div
class="list-group-item"
v-for="(element, index) in list2"
:key="element.name"
>
{{ element.name }} {{ index }}
</div>
</draggable>
</div>
<rawDisplayer class="col-3" :value="list1" title="List 1" />
<rawDisplayer class="col-3" :value="list2" title="List 2" />
</div>
</template>
<script>
import draggable from "@/vuedraggable";
export default {
name: "two-lists",
display: "Two Lists",
order: 1,
components: {
draggable
},
data() {
return {
list1: [
{ name: "John", id: 1 },
{ name: "Joao", id: 2 },
{ name: "Jean", id: 3 },
{ name: "Gerard", id: 4 }
],
list2: [
{ name: "Juan", id: 5 },
{ name: "Edgard", id: 6 },
{ name: "Johnson", id: 7 }
]
};
},
methods: {
add: function() {
this.list.push({ name: "Juan" });
},
replace: function() {
this.list = [{ name: "Edgard" }];
},
clone: function(el) {
return {
name: el.name + " cloned"
};
},
log: function(evt) {
window.console.log(evt);
}
}
};
</script>
This is straight from the draggable documentation found here on the "View Code" button: https://sortablejs.github.io/Vue.Draggable/#/two-lists
I am trying to understand what property is necessary to make it so each list knows the other is a drag and drop area. Unfortunately this isn't clarified in the doc, so anyone who can break it down I'd be ever so grateful!
I think it has something to do with
<draggable class="list-group" :list="list1" group="people" @change="log">
but unsure
The
vue-draggablelibrary is, as stated on the repo's README, based on another library called Sortable. So anything related to the draggable options are from this library and you should refer to its documentation.Here is the documentation for the
groupproperty:So yes, this property is the one responsible to link two draggable lists.