i wrote code shown below call lightbox show , callback function, example function_a, fire 16 times.
how can make fire once?
$("#open").click(function(){ $('.a, .b, .c, .d').fadeout(600,function(){ $('.e, .f, .g, .h').fadein(400,function(){ function_a(); }); }); }); function_a(){ console.log('fire') };
you can use $.fn.promise
, f.ex:
$("#open").click(function(){ $('.a, .b, .c, .d').fadeout(600).promise().done(function(){ $('.e, .f, .g, .h').fadein(400).promise().done(function(){ function_a(); }); }); });
from docs:
the .promise() method returns dynamically generated promise resolved once actions of type bound collection, queued or not, have ended.
also note classnames must @ least 2 characters long.
Comments
Post a Comment