]> 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:11:49 +0000 (11:11 -0500)
ui/jquery.ui.sortable.js

index dd01e1d6390d334a4a963ec4f77608d6897d7b68..05cbf2132ac5bf16df955635370ce1378af43f63 100644 (file)
@@ -377,21 +377,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;