Skip to content

Instantly share code, notes, and snippets.

@devcem
Created January 17, 2016 14:50
Show Gist options
  • Save devcem/3f6be212e123c5f181c1 to your computer and use it in GitHub Desktop.
Save devcem/3f6be212e123c5f181c1 to your computer and use it in GitHub Desktop.
Vue sortable component
//Javascript
Vue.component('sort', {
template: "#sort-template",
props : ['data', 'id'],
ready: function (value) {
Sortable.create(document.getElementById(this.id), {
draggable: 'li'
});
}
});
//HTML
<sort :data="list" id="listElement"></sort>
//HTML
<script type="text/x-template" id="sort-template">
<ul :id="id">
<li v-for="item in data">{{item}}</li>
</ul>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment