Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass vm method to group pull/put option? #37

Closed
fedenko opened this issue Dec 1, 2016 · 3 comments
Closed

How to pass vm method to group pull/put option? #37

fedenko opened this issue Dec 1, 2016 · 3 comments
Labels

Comments

@fedenko
Copy link

fedenko commented Dec 1, 2016

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?

@David-Desmaisons
Copy link
Member

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>

@fedenko
Copy link
Author

fedenko commented Dec 1, 2016

Thank you, @David-Desmaisons!

@David-Desmaisons
Copy link
Member

You´re welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants