Use jQuery promise() to create single callback after animate() on multiple itemsTöbb elem animálása utáni callback készítéséhez használj jQuery promise()-t
$('.listContainer .element').animate( {opacity:0}, { duration:2000, complete: function(){ // This would be called on each item } } ).promise().then(function() { // This will be called after all items faded });
OR
var items = $('.listContainer .element'); items.animate( {opacity:0}, { duration:2000, complete: function(){ // This would be called on each item } } ); items.promise(function() { // This will be called after all items faded });
is identical.
Read more: http://net.tutsplus.com/tutorials/javascript-ajax/wrangle-async-tasks-with-jquery-promises/