Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery callback within the remove() function

I need to call a function after a DIV has been removed from the page.

I have tried adding a callback like so, but no luck. Any suggestions?

$(foo).remove( function() {
   stepb();
});
like image 662
Jason Wells Avatar asked Dec 31 '12 20:12

Jason Wells


Video Answer


1 Answers

Try this

$.when($('#foo').remove()).then(stepb()); [Example1][1] and [Example2][2].

$('#foo').remove();
stepb();

​Since the remove method in jQuery is synchronous, stepb() will be invoked after remove() has finished. So, no need to use $.when().then().

like image 71
The Alpha Avatar answered Sep 22 '22 05:09

The Alpha