views:

202

answers:

3

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>
+2  A: 

try this, it might work:

$("a#later").click(function () {
   $("#box").fadeTo('slow', function() {
       $("#box").dialog("close")
   });
});
GerManson
No.. it just closes, no fade to effect.
Broken Link
i edited my answer.
GerManson
you are very close.. See the answer below.. the FadTo also needs a second parameter for the speed.
Broken Link
A: 

Try this:

            $(function () {
                $("#box").dialog({
                    autoOpen: true,
                    width: 500,
                    modal: true,
                    show: 'blind',
                    hide: 'fade'
                });
            });

Check out the example here: Animated Dialog

Giorgi
Aw Man.. It doesn't even load the dialog now, it hides by default :)
Broken Link
I have updated my answer.
Giorgi
Now it loads with a fade in effect.. it won't even close the dialog
Broken Link
That's really strange. Try removing 'show' option and check the link I posted to see how effects work and what are possible values for effect.
Giorgi
+1  A: 

How about

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

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

Kathy Van Stone
That's what I call it as Awesome!
Broken Link