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

sql server - NHibernate incorrectly creating ManyToMany table - Cannot define PRIMARY KEY constraint on nullable column error -

All overlapping substrings matching a java regex -

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