Sortable: Make sure we have a placeholder before trying to remove it during a cancel. Fixes #6879 - Sortable: Calling cancel when there is no sort occurring throws an error.

(cherry picked from commit f165c93127)
This commit is contained in:
marcos.sousa 2011-01-18 16:33:30 -02:00 committed by Scott González
parent 465c4c2cbe
commit 1ce8cf885f

View File

@ -378,6 +378,7 @@ $.widget("ui.sortable", $.ui.mouse, {
} }
if (this.placeholder) {
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! //$(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.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(); if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
@ -394,6 +395,7 @@ $.widget("ui.sortable", $.ui.mouse, {
} else { } else {
$(this.domPosition.parent).prepend(this.currentItem); $(this.domPosition.parent).prepend(this.currentItem);
} }
}
return this; return this;