简体   繁体   English

对jQuery UI对话框的关闭效果

[英]Effect on close for jQuery UI dialog

I'm using the following code for managing the jQuery UI dialog: 我正在使用以下代码来管理jQuery UI对话框:

$("#mydialog").dialog({
      autoOpen: false,
      title: "myDialog",
      modal: true,
      width: "800",
      hide: null,
      open: function(event, ui){  
        //some code
    },
     close: function(event, ui){ 
        $("#mydialog").dialog("option", "fade", null);       
    }
});

And then I open the dialog calling this code: 然后我打开调用此代码的对话框:

$("#mydialog").dialog("option", {
    modal: true
}).dialog("open");

This works fine, but I can't see any effect when I close the dialog. 这工作正常,但我关闭对话框时看不到任何效果。

How modify my code in order to obtain this result? 如何修改我的代码以获得此结果?

If i understand correctly you want your dialog to close with a fading effect. 如果我理解正确,你希望你的对话框关闭,褪色效果。

    $("#mydialog").dialog({
    autoOpen: false,
    title: "myDialog",
    modal: true,
    width: "800",
    hide: { effect: "fade", duration: 200 } //put the fade effect
});

The trick here is to have dialog actually close after fading process finishes, not before it. 这里的诀窍是在淡入淡出过程结束后让对话框实际关闭,而不是在它之前。

Try closing dialog using this code, it should do the trick: 尝试使用此代码关闭对话框,它应该做的伎俩:

$("#mydialog").fadeTo('slow', 0, function() {
  $("#mydialog").dialog('close');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM