I'm currently utilizing the Vue.Draggable plugin to create a draggable list feature. I have a sorted computed property being passed in this way:
data(){
return {
paymentMethods: [
{ name: 'stripe', Dindex: 0, state: 2 },
{ name: 'paypal', Dindex: 1 , state: 1 },
{ name: '2checkout', Dindex: 2, state: 4 },
{ name: 'cod', Dindex: 3, state: 3 }
],
}
},
computed: {
payments() {
return _.sortBy(this.paymentMethods, 'state');
},
}
Here is the Drag and Drop List setup:
<draggable :list="payments" class="payment-methods" tag="ul" @start="drag=true" @end="drag=false" @change="indexChanged">
<li v-for="(method, index) in payments" :key="index">
<!-- list data -->
</li>
</draggable>
The issue arises from the fact that the draggable functionality does not work as expected due to the manual sorting through lodash's _.sortBy
. My question is how can I implement sorting within a draggable list.