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 に答える