Vue.draggable: v-model type deep not work

Created on 18 Dec 2018  路  5Comments  路  Source: SortableJS/Vue.Draggable

With Vuex:
state:{
myObject:{list:[]}
}

<draggable v-model='myObject.list'>
computed: {
    myList: {
        get() {
            return this.$store.state.myObject.list
        },
        set(value) {
            //there is doesn't working!!!!!
            this.$store.commit('updateList', value)
        }
    }
}

https://jsfiddle.net/hq_zh/pmvwhwcq/309/

All 5 comments

Please create a jsfiddle.

@David-Desmaisons done

Also facing this issue. To add a bit more context to the issue, quite simply the setter is not being called and vuex will complain about trying to modify state without mutators

You have to use a computed for the array like this脟
https://jsfiddle.net/dede89/pdnxc01r/2/

I am also having some issues with this.
I am using a computed get() and set() to update some values in my store. However I am not exactly sure what is happening here.

the following code works, but it would mean i might need to have a ton of computed getters and setters.

      <draggable class="list-group" v-model="scrumdata" group="scrum" @change="log">
        <v-card v-for="element in scrumdata" :key="element.id">{{ element.name }}</v-card>
      </draggable>

```js
computed: {
scrumdata: {
get() {
return this.$store.getters.currentScrumData.scrum.todo;
},
set(val) {
console.log(val, "ok");
}
}
}

this works. [todo getter returns an array of objects] and calls the set(val) when the list changes

The following DOES NOT call the set(val) and I can't figure out why!

```html
      <draggable class="list-group" v-model="scrumdata.todo" group="scrum" @change="log">
        <v-card v-for="element in scrumdata.todo" :key="element.id">{{ element.name }}</v-card>
      </draggable>

  computed: {
    scrumdata: {
      get() {
        return this.$store.getters.currentScrumData.scrum;
      },
      set(val) {
        console.log(val, "ok");
      }
    }
  }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fedenko picture fedenko  路  3Comments

Kgwkgwkgw picture Kgwkgwkgw  路  3Comments

Laraveldeep picture Laraveldeep  路  3Comments

tomdong picture tomdong  路  3Comments

clemsontiger picture clemsontiger  路  3Comments