aam1r
aam1r

Reputation: 11

jQuery UI close Dialog when form submitted

I have been trying to do the follow:

I am trying the following code:

    $('#RegisterDialog').dialog({
               autoOpen: false,
                closeOnEscape: false,
                position: 'center',
                modal: true,
                width: 600,
                buttons: {
                    "Cancel account registration": function() { 
                        $(this).dialog("close"); 
                        window.location = 'http://localhost/';
                    } 
                }
});

$(".Register").click(function() {
           $('#RegisterDialog').dialog("close"); 
           $('#RegisterDialog').hide();
});

However, it hides and pops back up again. I also tried 'autoClose: false'.

Any help please?

Upvotes: 0

Views: 2382

Answers (3)

Ashu
Ashu

Reputation: 11

You should try .remove().

This will remove the element and it won't pop up again.

Upvotes: 1

Bang Dao
Bang Dao

Reputation: 5112

I think you should do like this

$(".Register").click(function() {
           $('#RegisterDialog').dialog("close"); 
           //$('#RegisterDialog').hide(); --> no need to call this
});

Upvotes: 0

Yves M.
Yves M.

Reputation: 3318

From the jQuery documentation...

.dialog( "destroy" ) 
// Remove the dialog functionality completely. This will return the element back to its pre-init state.

This might do the trick.

Upvotes: 0

Related Questions