Jquery Formatting - run function after another one has finished -


i have 2 jquery functions. first 1 below want run first, when function has finished, run other one. i'd add function first bit of code, not sure how i'd block or if it's correct way.

so in short, want code run...

$('#setuppanel').modal({         backdrop: "static",         keyboard: false }); 

after function has finished executing...

$('html, body').animate({         scrolltop: $("#header_wrap").offset().top }, 600); 

edit: here's entire function...

$(setup).click(function () {     $('html, body').animate({         scrolltop: $("#header_wrap").offset().top     }, 600);     $('#setuppanel').modal({         backdrop: "static",         keyboard: false     }); }); 

you can try promise() method:

$(setup).click(function () {     $('#setuppanel').modal({         backdrop: "static",         keyboard: false     }).promise().done(function() {         $('html, body').animate({             scrolltop: $("#header_wrap").offset().top         }, 600);           }); }); 

update:

you can use .animate() method's callback function:

$(setup).click(function () {         $('html, body').animate({             scrolltop: $("#header_wrap").offset().top         }, 600, function() {           $('#setuppanel').modal({               backdrop: "static",               keyboard: false           })       }}); }); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -