-
-
Save mxlje/6d92f6d7ad27702e8ecf 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()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
_.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; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment