Dragging items from one list to another, with dynamic lists in VueJS / SortableJS

Viewed 476

I'm trying to get Vue-Draggable to work with dynamic lists. I've got it working fine with static lists, but anything dynamic just doesn't seem to work.

Here is the script I've got at the moment:

        <template v-for="(group, groupkey) in managegroupmodal.groups">
            <div :key="'draggroup-' + groupkey">
                <h4>{{ group.emoji }} {{ group.title }}</h4>
                <draggable
                    :list="managegroupmodal.groups[groupkey].sets"
                    group="manageModalGroup"
                    class="alert row shadow-sm m-1 gutter-b minh50"
                >
                    <span
                        class="btn btn-sm btn-font-sm font-weight-bold m-1 btn-light-success"
                        v-for="myelement in managegroupmodal.groups[groupkey].sets"
                        :key="'dragitem-' + myelement.id"
                        >{{ myelement.emoji }} {{ myelement.title }}</span
                    >
                </draggable>
            </div>
        </template>

The issue is that whenever I drag and drop and element from one list to another it just goes back to it's initial list. I can't even drag & drop elements within a list to reorder them.

Is there something I'm missing?

Thanks

1 Answers

Ok I was able to fix the issue. It looks like one of the elements of the list had an extra key that some of the other elements of the list didn't have and it broke the script for some reason...

I've since cleaned everything up, made sure that all the elements of the list are formatted the exact same way, and it works as expected!

Related