Ivan Ivković Posted June 28, 2012 Share Posted June 28, 2012 Sometimes I can't actually control the order of functions jQuery or javascript. Maybe just my lack of understanding javascript. Like if I put function1(); function2(); it will not execute function1, then function2, but both at the same time. This is how I handle that: function loadAjaxPopup(width, height, widget, action, criteria){ mg_lft = - width / 2; mg_top = - height / 2; $('#background').animate({opacity: '0.45'}, 0).fadeIn(200); $('body:not(#background)').append('<div class="popup"></div>'); var done = true; if(done == true){ $('.popup').slideDown(200); $('.popup').animate({ height: height + 'px', marginTop : mg_top + 'px' }, 200); done2 = true; if(done2 == true){ $('.popup').animate({ width: width + 'px', marginLeft : mg_lft + 'px' },200 ); done3 = true; if(done3 == true){ $.get( '/ajax/' + widget + '/' + action + '/' + criteria, function(data){ $('.popup').append(data); $('.data').fadeIn(200); }, 'html' ); } } } } Is this a good or a bad way to handle my problem? What do you think? Quote Link to comment Share on other sites More sharing options...
Ivan Ivković Posted June 28, 2012 Author Share Posted June 28, 2012 Turns out it's not. done variable does not really get created after the animate function. Is there a better solution? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.