Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.2/Sortable.min.js"></script>  
<script src="https://npmcdn.com/vue-sortable@latest"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<meta name="description" content="VueSortable onUpdate Example">  
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>VueSortable</title>
</head>
<body>
  
  <h1 class="page-header">VueSortable Callback</h1>
  
  
  <h3>Sortable List</h3> 
  <ul class="list-group" v-sortable="{ onUpdate: onUpdate }">
    <li class="list-group-item" v-for="item in list">{{ item }}</li>
  </ul>
  
  <hr>
  
  <h3>Sorted Data Source</h3>
  <pre>{{ list | json }}</pre>
  
</body>
</html>
 
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])
    }
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
sagalbotpro
0viewers