Vue: Sortable with Vuejs, works in 1, doesn't work in 2

Created on 10 Nov 2016  ·  2Comments  ·  Source: vuejs/vue

I'm trying to make the sortable list two-way bound

Here's an example of HTML and array elements in vue 1

As you can see it works as expected.

Here's the same example ported to vue 2

it looks broken!

I think it's because the way vue 2 handles dom diffing? Or is it a bug? Is there a a way to work around it?

Most helpful comment

You could add a unique key for each list item, take a look at list rendering doc

I updated the fiddle here https://jsfiddle.net/defcc/9ne1m5js/2/

All 2 comments

You could add a unique key for each list item, take a look at list rendering doc

I updated the fiddle here https://jsfiddle.net/defcc/9ne1m5js/2/

It's because sortable works with the dom in place and Vue needs a hint to keep track of dom elements

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loki0609 picture loki0609  ·  3Comments

franciscolourenco picture franciscolourenco  ·  3Comments

finico picture finico  ·  3Comments

robertleeplummerjr picture robertleeplummerjr  ·  3Comments

lmnsg picture lmnsg  ·  3Comments