title: How to submit form within submit handler?
body: <p>I would like to add a confirm message that would popup when user tries to submit a form. I came up with the following, but this looks like a hack to me. </p>
  
  <pre><code>$('#someform').submit(function () {
    var form = $(this);
    //a hack so that this handler does not fire again, see below
    if (form.attr('data-confirm') == 'disabled') {
      return true;
    }
  
    showConfirmPopup({
      message: "Are you sure?",
      success: function () {
  
        form.attr('data-confirm', 'disabled');
        form.submit();
  
        hideConfirmPopup();
      }
    });
  
    return false;
  })
  </code></pre>
  
  <p>});</p>
  
  <p>So when user submits form this handler will catch the event and prevent, display popup and prevent form submit (by returning <code>false</code>). When user confirms, success handler will all form submit method and our handler will fire again, but this time it will return <code>true</code> and form will be submitted. </p>
  
  <p>Can this be achived without writing the <code>data-confirm</code> attribute?</p>