title: Custom confirm box in JQuery that returns a boolean value
body: <p>I am using JQuery &amp; JQuery UI and I tried using JQuery UI Dialog to solve this problem but I was unable to accomplish it.</p>
  
  <p>Basically I have for example this code that uses JS confirm box:</p>
  
  <pre><code>// if user presses cancel, do not proceed to the next section of the code
  if ( ! confirm('Are you sure you want to press OK?')) {
    return;
  }
  
  .... Lots of code below
  </code></pre>
  
  <p>I want to turn this to use a custom box that I can customize using CSS. I tried with UI dialog:</p>
  
  <pre><code>function confirmIt(text) {
     $('#confirm_dialog').dialog({
        width: 300,
        height: 150,
        buttons: {
           "OK": function() { return true; },
           "Cancel": function() { return false; }
        }
     });
  }
  
  if ( ! confirmIt('Are you sure you want to press OK?')) {
     return;
  }
  .... Lots of code below
  </code></pre>
  
  <p>Now the problem with above code is that a lot of code below the if condition still executes. I understand that JQuery Dialog is aync process, but I was wondering if there are such plugins for free out there that I could use that will return boolean value? Basically functionality wise it should work exactly same as JS <code>confirm()</code>. I do not want to wrap that a lot of code within the callback of JQuery UI dialog to achieve this. I just want to <strong>stop</strong> script execution if <code>CANCEL is clicked</code> and <strong>continue</strong> execution if <code>OK is clicked</code>.</p>