Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 f165c93)
  • Loading branch information...
commit 1ce8cf885f8f83b3c449629acb7124e31f4c71c3 1 parent 465c4c2
authored January 18, 2011 scottgonzalez committed January 19, 2011

Showing 1 changed file with 16 additions and 14 deletions. Show diff stats Hide diff stats

  1. 30  ui/jquery.ui.sortable.js
30  ui/jquery.ui.sortable.js
@@ -378,21 +378,23 @@ $.widget("ui.sortable", $.ui.mouse, {
378 378
 
379 379
 		}
380 380
 
381  
-		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
382  
-		if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
383  
-		if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
384  
-
385  
-		$.extend(this, {
386  
-			helper: null,
387  
-			dragging: false,
388  
-			reverting: false,
389  
-			_noFinalSort: null
390  
-		});
  381
+		if (this.placeholder) {
  382
+			//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  383
+			if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  384
+			if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  385
+
  386
+			$.extend(this, {
  387
+				helper: null,
  388
+				dragging: false,
  389
+				reverting: false,
  390
+				_noFinalSort: null
  391
+			});
391 392
 
392  
-		if(this.domPosition.prev) {
393  
-			$(this.domPosition.prev).after(this.currentItem);
394  
-		} else {
395  
-			$(this.domPosition.parent).prepend(this.currentItem);
  393
+			if(this.domPosition.prev) {
  394
+				$(this.domPosition.prev).after(this.currentItem);
  395
+			} else {
  396
+				$(this.domPosition.parent).prepend(this.currentItem);
  397
+			}
396 398
 		}
397 399
 
398 400
 		return this;

0 notes on commit 1ce8cf8

Please sign in to comment.
Something went wrong with that request. Please try again.