Opened 12 years ago
Closed 12 years ago
#9846 closed bug (worksforme)
.done() does not fire when animation has complete callback
Reported by: | KarlG | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | deferred | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I'm not completely sure this is a bug, but it does seem to be an unexpected change in behavior from 1.6.1 to 1.6.2. Here is the test case:
<!DOCTYPE html> <html> <head> <script type="text/javascript" src="/js/jquery-1.6.2.js"></script> <script type="text/javascript"> $(document).ready(function() { var slideUpAndRemove = function() { $(this).slideUp(function() { $(this).remove(); }); } var box = $("#box"); box.animate({ opacity : 0.0 }, { duration : 2000, complete : slideUpAndRemove }); $.when(box).done(function() { alert('done!'); }); }); </script> </head> <body> <div id="box" style="color:white;background-color:green;position:absolute;height:200px;width:200px">This is a test box</div> <div>Below the animated box</div> </body> </html>
In 1.6.1, the 'done!' alert box consistently appears. It does not in 1.6.2.
I have tested in FF 5 and Chrome 14 (Ubuntu 10.04).
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
The issue seems to be related to the fact that the elements are getting removed in the complete callback. This version accomplishes the same thing and works in 1.6.2:
So, like I said, I'm not sure if this counts as a bug but it is a change in behavior. I can live with the second alternative just fine.
comment:3 Changed 12 years ago by
Sorry, I seem to have faddled that last fiddle. Here's the alternative I meant to post:
comment:4 Changed 12 years ago by
Component: | unfiled → deferred |
---|---|
Priority: | undecided → low |
Resolution: | → worksforme |
Status: | new → closed |
Closing per OPs test case
Here's the test case in jsFiddle:
http://jsfiddle.net/yXPBY/
Toggle between loading the two versions to see the bug occur/not occur.