Skip to main content

Bug Tracker

Side navigation

#9846 closed bug (worksforme)

Opened July 16, 2011 10:48PM UTC

Closed July 17, 2011 12:24AM UTC

.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).

Attachments (0)
Change History (4)

Changed July 16, 2011 10:52PM UTC by anonymous comment:1

Here's the test case in jsFiddle:

http://jsfiddle.net/yXPBY/

Toggle between loading the two versions to see the bug occur/not occur.

Changed July 16, 2011 11:31PM UTC by anonymous comment:2

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:

http://jsfiddle.net/YRfJB/

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.

Changed July 16, 2011 11:34PM UTC by anonymous comment:3

Sorry, I seem to have faddled that last fiddle. Here's the alternative I meant to post:

http://jsfiddle.net/DTALV/

Changed July 17, 2011 12:24AM UTC by rwaldron comment:4

component: unfileddeferred
priority: undecidedlow
resolution: → worksforme
status: newclosed

Closing per OPs test case