title: Ajax.BeginForm OnBegin confirmation Via jquery modal
body: <p>I'm using jQuery UI dialog. I have a delete form as follows:</p>
  
  <pre><code>@using (Ajax.BeginForm("DeleteUser", "Administrator", new { id = Model }, new AjaxOptions { OnSuccess = "Deleted", OnBegin = "DeletingUser" }, new { id = "frm" + Model, name = Model }))
  {
      &lt;input type="submit" value="" /&gt;
  }
  </code></pre>
  
  <p>I want before the ajax request is sent, a modal confirmation pops up and the user selects a yes or no.</p>
  
  <p>Here is my javascript:</p>
  
  <pre><code>&lt;script&gt;
  function DeletingUser(){
      $( "#dialog-confirm" ).dialog({
          resizable: false,
          height:140,
          modal: true,
          buttons: {
              "Delete all items": function() {
                  $( this ).dialog( "close" );
              },
              Cancel: function() {
                  $( this ).dialog( "close" );
              }
          }
      });
              //I need to return a true or false here depending on the button clicked.
  }
  &lt;/script&gt;
  
  
  
  &lt;div id="dialog-confirm" title="Empty the recycle bin?"&gt;
  &lt;p&gt;&lt;span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"&gt;&lt;/span&gt;These items will be permanently deleted and cannot be recovered. Are you sure?&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>As seen in the javascript code, the dialog is opened asynchronously, which causes the method to return nothing and the form getting submitted anyways without the user selecting a yes or no. How do I fix this?</p>