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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.