views:

67

answers:

2

Hello,

I have been trying to do the follow:

  • Form gets showed inside jQuery Dialog
  • When form gets submitted, jQuery dialog should close

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?

A: 

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.

Yves M.
A: 

I think you should do like this

$(".Register").click(function() {
           $('#RegisterDialog').dialog("close"); 
           //$('#RegisterDialog').hide(); --> no need to call this
});
Bang Dao
Just tried it; doesn't work. I also tried .dialog("destroy") and that doesn't work either. It goes away for a second and comes back right away. Something keeps triggering it to come back up it seems
aam1r
Then pls give more detail, all of the code if possible...
Bang Dao