Skip to content

Commit b9ef00f

Browse files
Martin Hochscottgonzalez
Martin Hoch
authored andcommitted
Sortable: Fixed container change detection. Fixes #5159 - Remove and receive events on nested sortables.
1 parent 2b899cc commit b9ef00f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

ui/jquery.ui.sortable.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,15 +1008,17 @@ $.widget("ui.sortable", $.ui.mouse, {
10081008

10091009
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
10101010
if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
1011-
if(!$.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
1012-
if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
1013-
for (var i = this.containers.length - 1; i >= 0; i--){
1014-
if($.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
1015-
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1016-
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1017-
}
1018-
};
1019-
};
1011+
1012+
// Check if the items Container has Changed and trigger appropriate
1013+
// events.
1014+
if (this !== this.currentContainer) {
1015+
if(!noPropagation) {
1016+
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
1017+
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
1018+
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
1019+
}
1020+
}
1021+
10201022

10211023
//Post events to containers
10221024
for (var i = this.containers.length - 1; i >= 0; i--){

0 commit comments

Comments
 (0)