Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery dialog box - doesn't fade out before closing

I have div(box) on my page and I'm using this script to display div as dialog box. Inside that div I have a hyper link, On click of the hyper link I want to fade out the dialog box and close.. The content of the dialog fades out, but the border of the dialog box remains same. If I add $("#box").dialog('close') to the click function after fadeto there is no effect.. it just closes the dialog box completely. Any help? using jquery-ui-1.7.2

<script type="text/javascript">
            $(document).ready(function(){
                 $("a#later").click(function () { 

                $("#box").fadeTo('slow', 0);
                 })
             });
            $(function () {
                $("#box").dialog({
                    autoOpen: true,
                    width: 500,
                    modal: true,

                });
            });
</script>
like image 857
Broken Link Avatar asked May 03 '10 18:05

Broken Link


3 Answers

How about

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

You want the close to happen after the fade finishes, correct?

like image 50
Kathy Van Stone Avatar answered Nov 14 '22 06:11

Kathy Van Stone


try this, it might work:

$("a#later").click(function () {
   $("#box").fadeTo('slow', function() {
       $("#box").dialog("close")
   });
});
like image 3
Germán Rodríguez Avatar answered Nov 14 '22 06:11

Germán Rodríguez


I try the code of some Richard below and it works. You can provide the effect name as a string:

$("#dialog").dialog({
  hide: "fadeOut"
});

or you can provide a hash if you have additional options, such as:

$("#dialog").dialog({
  hide: {effect: "fadeOut", duration: 5000}
});
like image 2
user1142779 Avatar answered Nov 14 '22 04:11

user1142779