Vue.draggable: Drag/sort multiple components

Created on 8 Jan 2018  路  1Comment  路  Source: SortableJS/Vue.Draggable

Is it possible to use Draggable to sort multiple components?

For example:

<div v-for="step in trainingSteps">
    <draggable :list="step.Content">
        <text-component v-for="content in step.Content" :key="content.Id" :content="content" :step="step" v-if="content.Type == 'Text'"></text-component>
    </draggable>
    <draggable :list="step.Content">
        <question-component v-for="content in step.Content" :key="content.Id" :content="content" :step="step" v-if="content.Type == 'Question'"></question-component>
    </draggable>
</div>

Or:

<div v-for="step in trainingSteps">
    <draggable :list="step.Content">
        <text-component v-for="content in step.Content" :key="content.Id" :content="content" :step="step" v-if="content.Type == 'Text'"></text-component>
        <question-component v-for="content in step.Content" :key="content.Id" :content="content" :step="step" v-if="content.Type == 'Question'"></question-component>
    </draggable>
</div>

I would like to be able to use different components depending on the type of content from the same list so that they can use different templates. I'm still new to Vue though so maybe I'm going about this wrong... but is this possible with Vue.Draggable? I want to be able to drag the 'question-component' above the 'text-component' for example.

Most helpful comment

The list value should be the same as the v-for of the inner element. So none of your mark-up will work.
Create an intermediate component will work thougth:

paragraph-component:
````html
````

<draggable :list="step.Content">
    <paragraph-component :content="content"  :key="content.Id" />
</draggable>

>All comments

The list value should be the same as the v-for of the inner element. So none of your mark-up will work.
Create an intermediate component will work thougth:

paragraph-component:
````html
````

<draggable :list="step.Content">
    <paragraph-component :content="content"  :key="content.Id" />
</draggable>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

iou90 picture iou90  路  3Comments

parthibeyond picture parthibeyond  路  3Comments

Kgwkgwkgw picture Kgwkgwkgw  路  3Comments

AlexandreBonneau picture AlexandreBonneau  路  3Comments

Stetzon picture Stetzon  路  3Comments