0

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?

2
  • Hmmm, just a note. This gets executed on document load. Could that be a problem? When the form gets executed, it makes a query to the same page. Commented Aug 9, 2010 at 19:00
  • 1
    Currently you have autoOpen: false, and dialog should not pop up after page loaded. Then how do you show your dialog, where is the $('#RegisterDialog').dialog("open"); triggered? Commented Mar 3, 2011 at 20:27

3 Answers 3

1

You should try .remove().

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

I think you should do like this

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

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.