Vue.draggable: How to pass vm method to group pull/put option?

Created on 1 Dec 2016  路  3Comments  路  Source: SortableJS/Vue.Draggable

Hi. I'm migrating my widget from nestedSortable to vue.
I have nested list and I need to limit list levels to 2. So I decided to use Sortable.js group put option. But how can I use a function in group put option with Vue.Draggable?

question

Most helpful comment

Like this:

<template>
<draggable :list="locations" :options="draggableOptions">
    <li v-for="location in locations">
        {{ location.name }}
    </li>
</draggable>
</template>

<script>
    import draggable from 'vuedraggable';
    export default {

        components: {
            draggable,
        },

        data() {
            return{
                locations: [
                    {id: 1, name: "location1"},
                    {id: 2, name: "location2"},
                    {id: 3, name: "location3"}
                ],
                draggableOptions: {
                   group: {
                      name: 'qux',
                      put: function (to) {
                         return to.el.children.length < 4;
                      }
                   },
                },
            }
        },
    }
</script>

All 3 comments

Like this:

<template>
<draggable :list="locations" :options="draggableOptions">
    <li v-for="location in locations">
        {{ location.name }}
    </li>
</draggable>
</template>

<script>
    import draggable from 'vuedraggable';
    export default {

        components: {
            draggable,
        },

        data() {
            return{
                locations: [
                    {id: 1, name: "location1"},
                    {id: 2, name: "location2"},
                    {id: 3, name: "location3"}
                ],
                draggableOptions: {
                   group: {
                      name: 'qux',
                      put: function (to) {
                         return to.el.children.length < 4;
                      }
                   },
                },
            }
        },
    }
</script>

Thank you, @David-Desmaisons!

You麓re welcome

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mathlet0x picture mathlet0x  路  4Comments

AlexandreBonneau picture AlexandreBonneau  路  3Comments

bborn picture bborn  路  3Comments

clemsontiger picture clemsontiger  路  3Comments

ghost picture ghost  路  3Comments