A
A
Arthur2019-06-17 11:22:19
Vue.js
Arthur, 2019-06-17 11:22:19

Reorder array elements on drag-n-drop?

Hello. A list of tasks that is taken from the VUEX repository, tasks can be rearranged by drag-n-drop. How to update the array in storage depending on the position of the task at the moment. Todo list

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-06-17
@Artiiiii

We include Vue.Draggable .
Add a setter to the allTasks computed property:

allTasks: {
  get() {
    return this.$store.state.tasks;
  },
  set(val) {
    this.$store.commit('allTasks', val);
  },
},

And we add a wrapper to the list in the form of a draggable component:
draggable.tasks__wrap(v-model="allTasks")
  ...

https://jsfiddle.net/sLmw2tbp/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question