Drop into multiple dynamic lists
Hello guys! Thanks for this great job!
I´m trying to drag an item from a list to another like "Trello". The other lists are dynamic, so I´ll never know the number of lists will be rendered. Let me try to explain better:
Scenario:
On the left of the screen, there is this list of items for the manager to distribute for the employers. The other part of the screen are lists of employers (which I´ll never know the right amount) so the manager can drag an item to a single employer and save to the data table on droping.
The problem I am facing is that when I drag to one employer, all the employers receive the same item. And the second issue is that I can´t which event I´ll use to trigger the AJAX request to save to the data base.
Let´s see some code: This image shows what happens when I drag and drop an item to the first guy!

The blade file:
<div class="row" >
<div class="col-md-12 p20">
</div>
<div class="col-md-3 col-sm-3">
<h5>Leads</h5>
<ul class="list-group drag p10">
<draggable class="dragArea"
:options="{group:'ITEMS'}"
v-model="leads">
<li class="list-group-item"
v-for="lead, index in leads"
:key="lead.no">
<span class="badge">No.@{{ lead.id }}</span>
<label>
@{{ lead.nome }}
</label>
</li>
</draggable>
</ul>
</div>
<div class="col-md-3 col-sm-3" v-for="corretor, index in corretores">
<h5>@{{ corretor.name }}</h5>
<ul class="list-group drag p10">
<draggable class="dragArea"
:options="{group:'ITEMS'}"
v-model="corretoresComLeads">
<li class="list-group-item" v-for="lead, index in corretoresComLeads">
<span class="badge">No.@{{ lead.id }}</span>
<label>
@{{ lead.nome }}
</label>
<span class="del" v-on:click="deleteItem(lead, index, '2')"><i class="fa fa-times"></i></span>
</li>
</draggable>
</ul>
</div>
</div>
The script part of the blade file:
@section('scripts')
<script src="//cdn.jsdelivr.net/npm/[email protected]/Sortable.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.15.0/vuedraggable.min.js"></script>
<script>
var vu = new Vue({
el: '#app',
data: {
leads: {!! $leads !!},
corretores: {!! $corretores !!},
corretoresComLeads: [],
marcado: [],
leadsCorretor: [],
corretor: ''
},
methods: {
deleteItem: function(item, index, group){
switch (group) {
case '':
var ITEMS = this.leads;
break;
case '2':
var ITEMS = this.leads2;
break;
case '3':
var ITEMS = this.leads3;
break;
case '4':
var ITEMS = this.leads4;
break;
}
ITEMS.splice(index, 1);
},
},
computed: {
myList: {
get() {
return this.leads;
},
set(value) {
this.leads = value;
}
},
myList2: {
get() {
return this.items2;
},
set(value) {
this.items2 = value;
}
},
myList3: {
get() {
return this.items3;
},
set(value) {
this.items3 = value;
}
},
myList4: {
get() {
return this.items4;
},
set(value) {
this.items4 = value;
}
},
enviaLead(id) {
const vm = this;
axios.post('/enviaLeads', {
lead: this.marcado,
user_id: id,
status_id: 0
})
.then(function (response) {
document.getElementById(response.data).style.display = "none";
vm.marcado = []
vm.corretoresComLeads.push(response)
});
},
removeLead(id) {
const vm = this
axios.post('/removeLead', {
id: id,
user_id: 0
})
.then(function (response) {
vm.corretoresComLeads.splice(response.data.id, 1)
//vm.corretoresComLeads.$remove(response.data.id)
});
}
}
});
</script>
@endsection
```
Please address this on stackoverflow as per contributing guideline.
How do I do it?
Did someone resolve this?
Nobody solved it, even the member @David-Desmaisons . You see this, bro, but i can't image how can you see it and don't help us.
Looks like @David-Desmaisons already answered the question in another thread.
<div v-for="list in lists">
<draggable v-model="list">
......
</draggable>
<div>
It worked for me.