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