Skip to content

Commit

Permalink
Sortable: Make sure we have a placeholder before trying to remove it …
Browse files Browse the repository at this point in the history
…during a cancel. Fixes #6879 - Sortable: Calling cancel when there is no sort occurring throws an error.

(cherry picked from commit f165c93)
  • Loading branch information
marcos.sousa authored and scottgonzalez committed Jan 19, 2011
1 parent 465c4c2 commit 1ce8cf8
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions ui/jquery.ui.sortable.js
Expand Up @@ -378,21 +378,23 @@ $.widget("ui.sortable", $.ui.mouse, {

}

//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();

$.extend(this, {
helper: null,
dragging: false,
reverting: false,
_noFinalSort: null
});
if (this.placeholder) {
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();

$.extend(this, {
helper: null,
dragging: false,
reverting: false,
_noFinalSort: null
});

if(this.domPosition.prev) {
$(this.domPosition.prev).after(this.currentItem);
} else {
$(this.domPosition.parent).prepend(this.currentItem);
if(this.domPosition.prev) {
$(this.domPosition.prev).after(this.currentItem);
} else {
$(this.domPosition.parent).prepend(this.currentItem);
}
}

return this;
Expand Down

0 comments on commit 1ce8cf8

Please sign in to comment.