Javascript 暂停执行,直到其他动画完成jQuery
我打开了几个对话框,如下所示:Javascript 暂停执行,直到其他动画完成jQuery,javascript,jquery,ajax,dialog,rendering,Javascript,Jquery,Ajax,Dialog,Rendering,我打开了几个对话框,如下所示: $("#dialog").load("/ajax/content.php"); $("#dialog").dialog({....}); 和一个全局事件监视器来设置对话框打开的动画 $(document).on("dialogOpen", ".dialogClass", function() { var parent = $(this).parent(); parent.css("left","-768px"); pare
$("#dialog").load("/ajax/content.php");
$("#dialog").dialog({....});
和一个全局事件监视器来设置对话框打开的动画
$(document).on("dialogOpen", ".dialogClass", function() {
var parent = $(this).parent();
parent.css("left","-768px");
parent.animate({
left:0
}, speed, "easeOutBounce");
}
在某些页面上,这看起来很不稳定。我怀疑这些动画是在对话框加载和呈现其ajax调用的结果时发生的。是否有任何方法可以暂停,直到所有其他动画完成,例如:
$(document).on("dialogOpen", ".dialogClass", function() {
//Wait until other rendering is complete prior to executing further
var parent = $(this).parent();
parent.css("left","-768px");
parent.animate({
left:0
}, speed, "easeOutBounce");
}
你考虑过吗
请访问:
有了它,您可以建立一个特定的队列顺序,您希望您的动画遵循这个顺序。jquery回调功能可能会有所帮助 在所有其他渲染完成后调用要执行的函数。。像 操作完成后显示警报的简单示例
$(document).ready(function(){
$("button").click(function(){
$("p").hide("slow",function(){
somefunction(); // this will execute after the completion of function
});
});
});
somefunction()
{
alert("The paragraph is now hidden");
}