Skip to content

Commit e0cc0ba

Browse files
committed
Pass dragged item to sortupdate event in a compatible way with jquery-ui.
1 parent 39d3d78 commit e0cc0ba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Use `.sortable-dragging` and `.sortable-placeholder` CSS selectors to change the
2323
Use `sortupdate` event if you want to do something when the order changes (e.g. storing the new order):
2424

2525
``` javascript
26-
$('.sortable').sortable().bind('sortupdate', function(e, draggedItem) {
26+
$('.sortable').sortable().bind('sortupdate', function(e, ui) {
27+
//ui.item contains the current dragged element.
2728
//Triggered when the user stopped sorting and the DOM position has changed.
2829
});
2930
```
@@ -84,7 +85,7 @@ yepnope({
8485
yep: 'jquery.sortable.js',
8586
nope: 'jquery-ui.min.js',
8687
complete: function() {
87-
$('.sortable').sortable().bind('sortupdate', function(e, draggedItem) {
88+
$('.sortable').sortable().bind('sortupdate', function(e, ui) {
8889
//Store the new order.
8990
}
9091
}

jquery.sortable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ $.fn.sortable = function(options) {
4646
dragging.removeClass('sortable-dragging').fadeIn();
4747
placeholders.detach();
4848
if (index != dragging.index()) {
49-
items.parent().trigger('sortupdate', dragging);
49+
items.parent().trigger('sortupdate', {item: dragging});
5050
}
5151
dragging = null;
5252
}).not('a[href], img').on('selectstart.h5s', function() {

0 commit comments

Comments
 (0)