Created
September 19, 2012 17:00
-
-
Save kjantzer/3750782 to your computer and use it in GitHub Desktop.
jQuery sortableWithIndexWatch - modified jquery ui sortable widget to store before and after index of moved item
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
// custom Sortable widget - gets before and after index of moved item | |
// https://gist.github.com/3750782 | |
$.widget("ui.sortableWithIndexWatch", $.extend({}, $.ui.sortable.prototype, { | |
_trigger: function() { | |
switch(arguments[0]){ | |
case 'start': | |
this.currentItem.indexStart = this.currentItem.index(); | |
break; | |
case 'update': | |
this.currentItem.indexEnd = this.currentItem.index(); | |
break; | |
} | |
return $.ui.sortable.prototype._trigger.apply(this, arguments); | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just for a reference: use $(this).data()['ui-sortable'].currentItem in this case.