0

我有几个对话框打开如下:

  $("#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");
 }
4

2 回答 2

0

可能是 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"); 
}
于 2012-12-21T19:10:35.133 回答
0

你考虑过 jQuery .queue()吗?

在以下位置查看:http ://api.jquery.com/queue/

有了这个,你可以建立一个你希望你的动画遵循的特定队列顺序

于 2012-12-21T19:00:24.457 回答