Skip to content

Commit 18c13fd

Browse files
committed
Trigger sortupdate event when the user stopped sorting and the DOM position has changed.
1 parent 47da2b9 commit 18c13fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jquery.sortable.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
*/
88
jQuery.fn.sortable = function() {
99
return this.each(function() {
10-
var $ = jQuery, dragging, dropHandler, dragHandler, items = $(this).children();
10+
var $ = jQuery, index, dragging, dropHandler, dragHandler, items = $(this).children();
1111
var dropHandler = function(e) {
1212
if (!dragging) return true;
1313
e.stopPropagation();
14-
placeholder.after(dragging);
14+
placeholder.before(dragging);
15+
if (index != dragging.index()) {
16+
items.parent().trigger('sortupdate');
17+
}
1518
return false;
1619
};
1720
var dragHandler = function(e) {
@@ -32,6 +35,7 @@ jQuery.fn.sortable = function() {
3235
dt.effectAllowed = 'move';
3336
dt.setData('Text', 'dummy');
3437
dragging = $(this).addClass('sortable-dragging');
38+
index = dragging.index();
3539
}).bind('dragend', function() {
3640
dragging.removeClass('sortable-dragging').fadeIn();
3741
placeholder.detach();

0 commit comments

Comments
 (0)