An open API service indexing awesome lists of open source software.

https://github.com/arkdevuk/vue2-sortable

A lightweight directive for reorderable drag-and-drop lists using RubaXa/Sortable based on https://github.com/sagalbot/vue-sortable
https://github.com/arkdevuk/vue2-sortable

javascript sortablejs vuejs vuejs-directive vuejs2 vuejs2-directive

Last synced: about 2 months ago
JSON representation

A lightweight directive for reorderable drag-and-drop lists using RubaXa/Sortable based on https://github.com/sagalbot/vue-sortable

Awesome Lists containing this project

README

          

# vue2-sortable

> Easily add drag-and-drop sorting to your Vue.js applications using the v-sortable2 directive, a thin wrapper for the minimalist [RubaXa/SortableJS](https://github.com/RubaXa/Sortable) library.
Based on [sagalbot/vue-sortable](https://github.com/sagalbot/vue-sortable)

Installation
--

#### NPM

https://www.npmjs.com/package/vue2-sortable

```bash
npm install vue2-sortable
```

Setup

```javascript
import Vue from 'vue'
import Sortable2 from 'vue2-sortable'

Vue.use(Sortable2)
```

Common Use Cases
--

#### Update Source Data Order

```javascript
new Vue({
el: 'body',
data: {
list: ['Foo', 'Bar', 'Baz']
},
methods: {
onUpdate: function (event) {
this.list.splice(event.newIndex, 0, this.list.splice(event.oldIndex, 1)[0])
}
}
});
```

```html


  • {{ item }}


```

Contributing
--

Feel free to fork or PR :)