最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Effect on close for jQuery UI dialog - Stack Overflow

programmeradmin5浏览0评论

I'm using the following code for managing the jQuery UI dialog:

$("#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?

I'm using the following code for managing the jQuery UI dialog:

$("#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?

Share Improve this question asked Sep 25, 2013 at 19:39 GVillani82GVillani82 17.4k32 gold badges109 silver badges176 bronze badges 2
  • What effect do you want to see? – Evan Davis Commented Sep 25, 2013 at 19:41
  • fade effect for example – GVillani82 Commented Sep 25, 2013 at 19:42
Add a ment  | 

2 Answers 2

Reset to default 8

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');
});
发布评论

评论列表(0)

  1. 暂无评论