title: jquery ui dialog box as confirm
body: <p>I am, trying to replicate the 'confirm' box of javascript using jquery dialog. This is my code,</p>
  
  <pre><code>function customConfirm(customMessage) {
          $("#popUp").html(customMessage);
          $("#popUp").dialog({
              resizable: false,
              height: 240,
              modal: true,
              buttons: {
                  "OK": function () {
                      $(this).dialog("close");
                      alert(true);
                      return true;
                  },
                  Cancel: function () {
                      $(this).dialog("close");
                      alert(false);
                      return false;
                  }
              }
          });
      }
  </code></pre>
  
  <p>But when I tried to alert this method, it shows 'undefined'. It is not waiting for the popup to display. How can i make this customConfirm function to wait for the users input(ok/cancel)?. 
  My need is that, customConfirm() method will return either true of false according to user input.</p>