views:

37

answers:

1

I have a div that I want to remove using remove(). I want to show an animation before/while removal of div. I have only been able to show the animation when hiding the div.

If i want to show the animation then do remove(). How is this done???

Code so far:

//Delete Button - delete from cart
$('.ui-icon-trash').live('click',function() {
    $(this).closest('li').hide("puff", {}, 1000)
});
+4  A: 

Do it in the callback function for .hide() (jQuery UI .hide() reference), like this:

$('.ui-icon-trash').live('click', function() {
  $(this).closest('li').hide("puff", {}, 1000, function() {
    $(this).remove();
  });
});

The function at the end runs as a callback, executing when the animation is done...so when you want :)

Nick Craver