Skip to content

Commit

Permalink
Draggable/Sortable: Partial fix for #4009: Fixed ui hash for sortable…
Browse files Browse the repository at this point in the history
… activate/deactivate callback when receiving a draggable.
  • Loading branch information
scottgonzalez committed Feb 5, 2009
1 parent 2f2342c commit fc9ebfb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ui/ui.draggable.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ $.extend($.ui.draggable, {
$.ui.plugin.add("draggable", "connectToSortable", { $.ui.plugin.add("draggable", "connectToSortable", {
start: function(event, ui) { start: function(event, ui) {


var inst = $(this).data("draggable"), o = inst.options; var inst = $(this).data("draggable"), o = inst.options,
uiSortable = $.extend({}, ui, { item: inst.element });
inst.sortables = []; inst.sortables = [];
$(o.connectToSortable).each(function() { $(o.connectToSortable).each(function() {
var sortable = $.data(this, 'sortable'); var sortable = $.data(this, 'sortable');
Expand All @@ -446,15 +447,16 @@ $.ui.plugin.add("draggable", "connectToSortable", {
shouldRevert: sortable.options.revert shouldRevert: sortable.options.revert
}); });
sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
sortable._trigger("activate", event, inst); sortable._trigger("activate", event, uiSortable);
} }
}); });


}, },
stop: function(event, ui) { stop: function(event, ui) {


//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
var inst = $(this).data("draggable"); var inst = $(this).data("draggable"),
uiSortable = $.extend({}, ui, { item: inst.element });


$.each(inst.sortables, function() { $.each(inst.sortables, function() {
if(this.instance.isOver) { if(this.instance.isOver) {
Expand All @@ -478,7 +480,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {


} else { } else {
this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
this.instance._trigger("deactivate", event, inst); this.instance._trigger("deactivate", event, uiSortable);
} }


}); });
Expand Down

0 comments on commit fc9ebfb

Please sign in to comment.