diff options
author | marcos.sousa <marcos.sousa@corp.globo.com> | 2011-01-18 16:33:30 -0200 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-01-19 11:13:16 -0500 |
commit | 1ce8cf885f8f83b3c449629acb7124e31f4c71c3 (patch) | |
tree | 4a020d0d381fbdecc1c57da1a92b2463bff272bb | |
parent | 465c4c2cbef33fc4491d862245180b6441875c15 (diff) | |
download | jquery-ui-1ce8cf885f8f83b3c449629acb7124e31f4c71c3.tar.gz jquery-ui-1ce8cf885f8f83b3c449629acb7124e31f4c71c3.zip |
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 f165c93127495d5041c3d49fa592fddbe8000bd1)
-rw-r--r-- | ui/jquery.ui.sortable.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 5ba82c312..a48350f27 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -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; |