sagalbot / vue-sortable

A lightweight directive for reorderable drag-and-drop lists using RubaXa/Sortable
http://sagalbot.github.io/vue-sortable/
MIT License
721 stars 104 forks source link

Has some problem use this in vue 2.0 #15

Open scq000 opened 8 years ago

scq000 commented 8 years ago

When use v-sortable directive , the code gives following exception:

Uncaught Sortable: `el` must be HTMLElement, and not [object Undefined]

And nothing gets rendered. Libraries versions used:

"sortablejs": "^1.4.2",
"vue": "^2.0.1",
"vue-sortable": "^0.1.3"
MunGell commented 8 years ago

This library is not compatible with Vue.js 2.0 at the moment due to significant API changes in the new version.

Update: there is a PR for supporting v2: https://github.com/sagalbot/vue-sortable/pull/13

revati commented 8 years ago

I added issue in vuejs repository https://github.com/vuejs/vue/issues/4085 I got it working (sort of) It has odd bug (dom does not sync with state)

FrankFang commented 7 years ago

https://github.com/sagalbot/vue-sortable/issues/10#issuecomment-272709457

chamberlainpi commented 7 years ago

:+1:

yunbiji commented 6 years ago

谢谢 @FrankFang 提供的方案 https://github.com/sagalbot/vue-sortable/issues/10#issuecomment-272709457

// your Vue
import Vue from 'vue'
import Sortable from 'sortablejs'

Vue.directive('sortable', {
  inserted: function (el, binding) {
    new Sortable(el, binding.value || {})
  }
})

之前自己的

// your Vue
import Sortable from 'sortablejs'
Vue.use(Sortable);
// vue-sortable/vue-sortable.js
Vue.directive('sortable', function (el, options) {
      options = options || {}
      var sortable = new Sortable(el || this.el, options)