]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Make sure we have a placeholder before trying to remove it during a cancel...
authormarcos.sousa <marcos.sousa@corp.globo.com>
Tue, 18 Jan 2011 18:33:30 +0000 (16:33 -0200)
committerScott González <scott.gonzalez@gmail.com>
Wed, 19 Jan 2011 16:13:16 +0000 (11:13 -0500)
(cherry picked from commit f165c93127495d5041c3d49fa592fddbe8000bd1)

ui/jquery.ui.sortable.js

index 5ba82c3123fdc27d490c48e134e11d415908139e..a48350f27262e2985d552e8e76f8bd17523e9bde 100644 (file)
@@ -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;