]> source.dussan.org Git - jquery-ui.git/commitdiff
sortable:fixed #3019, stop being fird too early
authorPaul Bakaus <paul.bakaus@googlemail.com>
Tue, 24 Jun 2008 11:47:42 +0000 (11:47 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Tue, 24 Jun 2008 11:47:42 +0000 (11:47 +0000)
tests/sortable.js
ui/ui.sortable.js

index 95fd9cbfd3e1d2adeadf940f73a1600e9f240e22..c9da3b729495d23ce2f0319884a5490a4d32ef01 100644 (file)
@@ -122,5 +122,17 @@ test("defaults", function() {
 \r
 });\r
 \r
+test("#3019: Stop fires too early", function() {\r
+       \r
+       var helper = null;\r
+       el = $("#sortable").sortable({ stop: function(e, ui) {\r
+               helper = ui.helper;\r
+       }});\r
+       \r
+       sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable');\r
+       equals(helper, null, "helper should be false");\r
+\r
+});\r
+\r
 \r
 })(jQuery);\r
index c3ce88ef29417305d226f7dff6b10a174c644d8d..2426c81f4dad5ab9113f96adfc8ac8fddf55fb3d 100644 (file)
@@ -519,11 +519,9 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                                left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
                                top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
                        }, parseInt(this.options.revert, 10) || 500, function() {
-                               self.propagate("stop", e, null, noPropagation);
                                self.clear(e);
                        });
                } else {
-                       this.propagate("stop", e, null, noPropagation);
                        this.clear(e, noPropagation);
                }
 
@@ -554,10 +552,15 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
                }
                
                this.dragging = false;
-               if(this.cancelHelperRemoval) return false;
+               if(this.cancelHelperRemoval) {
+                       this.propagate("stop", e, null, noPropagation);
+                       return false;
+               }
+               
                $(this.currentItem).css('visibility', '');
                if(this.placeholder) this.placeholder.remove();
-               this.helper.remove();
+               this.helper.remove(); this.helper = null;
+               this.propagate("stop", e, null, noPropagation);
                
                return true;