1

I've this function in jQuery:

    $("#bottone_mail").on("click", function(){
        $('#container_body').fadeTo(1000, 0.25);
        $( "#form" ).dialog({
            width:510,height:500});
            return false;

That creates a form window. When the user clicks the "Send" button, this script is executed:

        $("#invia").on("click", function(){
        $( "#form" ).dialog("close");
        $('#container_body').fadeTo(1000, 1);
        $("#spc1").html("<div id='mess_invio'> Messaggio inviato con successo, grazie!</div>");
        return false;
        });

I want $('#container_body').fadeTo(1000, 1); to be executed when the user closes the form window with the "X" button, other than when the "Send" button is pressed.

The only related answer I could find is this: jQuery UI Dialog Box - does not open after being closed

It doesn't work for me, though, as a function name is required.

I'm at my first steps with jQuery, so I'd be very thankful if someone was to post a tailored solution with an explanation...

Community
  • 1
  • 1

2 Answers2

0

You can do it like this -

$("#form").on('dialogclose', function(event) {
   $('#container_body').fadeTo(1000, 1);
});
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
0

you have options when you create the dialog.

Maybe you can use something like:

$( "#form" ).dialog({
        width:510,
        height:500,
        close: function() {
                    $('#container_body').fadeTo(1000, 1);
        }
});
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125