Jump to content

Action orders? Is this a good way to handle them?


Ivan Ivković

Recommended Posts

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.