Skip to content

Instantly share code, notes, and snippets.

@kjantzer
Created October 29, 2012 16:50
Show Gist options
  • Save kjantzer/3974823 to your computer and use it in GitHub Desktop.
Save kjantzer/3974823 to your computer and use it in GitHub Desktop.
Underscore.js Mixin: Move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
/*
_.move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
*/
_.mixin({
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
}
});
@kjantzer
Copy link
Author

$.Sortable mod for getting indexes:
https://gist.github.com/3750782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment