farhadi/html5sortable — pull request #27 by flying-sheep (2012-10-07 20:00:43+00:00)
Title: Add oldindex property to sortupdate event data

knowing the old index is a useful feature for using this in an MVVC application, since the underlying array can be spliced instead of having to be rewritten.

AngularJS example:

```html

```

```javascript
function SortableCTRL($scope) {
$scope.sortableArray = ['One', 'Two', 'Three'];

$scope.sortupdate = function(e, data) {
var start = data.oldindex,
end = data.item.index();

$scope.sortableArray.splice(end, 0,
$scope.sortableArray.splice(start, 1)[0]);

$scope.$apply();
};

setTimeout(function() {//applies this after the items are generated is rendered
$('#sortable')
.sortable()
.on('sortupdate', $scope.sortupdate);
});
}
```