0

I try to use form submit with jquery modal dialog. Look at following code.

$(function() {

var sendConfirmation = false;

$( "#dialog-form" ).dialog({
  autoOpen: false,
  height: 300,
  width: 350,
  modal: true,
  buttons: {
    "Send": function() {
        sendConfirmation = true;
    },
    "Close": function() {
        $(this).dialog("close");
    }
  }
});

$("#send").submit(function(event) {
    //If user click on modal dialog "Send", then submit should be trigger.
    //And if user click "Close"
    $(this).trigger("recaptcha");
    return false;
    /*if(sendConfirmation) {
        return true;
    } else {
        return false;
    }*/

});

$("#send").bind("recaptcha", function() {
        $( "#dialog-form" ).dialog( "open" );
        //return false;
    }); 
  });

If the user click on submit button, the dialog will be open and submit should be wait until the "OK" button on modal dialog is clicked, then submit should be execute.
the main idea is, when user click on submit button modal dialog will be open and on the modal dialog is the recaptcha. The user put recaptcha code and click on OK button and data should be submit.

5
  • Good!! Now what is your question? Commented Feb 6, 2013 at 9:01
  • How can i stop the submit flow, until the OK button is click? If user click on OK button on modal dialog, then the form should be submit. Commented Feb 6, 2013 at 9:19
  • something occurred to me is, what i want is a before and after filter around submit, like rails filter. Commented Feb 6, 2013 at 9:39
  • i solve the problem through define a variable from type boolean. at the beginning, the variable is set false. After the user click OK button on Dialog, the variable will be set true and the form will be submit. In submit function, i validate if variable is true, if yes return true other false. Commented Feb 6, 2013 at 10:17
  • Good that your issue is solved. Commented Feb 6, 2013 at 10:34

1 Answer 1

1

JavaScript is single-threaded and since JavaScript is being used to display the dialog and handle any clicks on it, there's no way to block execution without blocking the UI . Try to use tha callback functions of the dialog buttons

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

Comments

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.