I have this javascript:
triggerAnimation(listItem,toggleToggleRadioListItem(listItem));
function triggerAnimation(listItem,passThruFunction){
listItem.find(".inlineLoading").show();
// pause and then call the toggle function
$("body").animate({opacity: 1}, 1000,
function(){
alert("a");
passThruFunction;
}
);
}
function toggleToggleRadioListItem(listItem) {
alert("b");
};
What is supposed to happen:
Based on the above, I'd expect the alert A to appear before alert B but that is not the case. What happens is that (it seems) alert B is called as soon as triggerAnimation() is called. Why is that? How can I achieve that behavior?
You can delay the execution by passing in a function and calling it later.
triggerAnimation(listItem, function () {
toggleToggleRadioListItem(listItem)
});
function triggerAnimation(listItem,passThruFunction){
listItem.find(".inlineLoading").show();
// pause and then call the toggle function
$("body").animate({opacity: 1}, 1000,
function(){
alert("a");
passThruFunction();
}
);
}
function toggleToggleRadioListItem(listItem) {
alert("b");
};