title: jQuery Deferred and Dialog box
body: <pre><code>function ValidateField(){
  var bAllow= true;
  
      //some checking here
  
  if (bAllow == true &amp;&amp; apl.val().trim() == "")
  { 
      showDialog(); 
      showDialog().done(function() {
          return true; // wanna return true, but not success
      }).fail(function() {
          return false; //wanna return false, but not success
      });
      return false; //stop it to execute to next line
  }
  return bAllow; //success return }
  
  function showDialog(){
  var def = $.Deferred();
  var modPop = '&lt;div id="diaCom" title="Information?"&gt;&lt;p&gt;something something&lt;/p&gt;&lt;/div&gt;';
  $("#diaCom").remove();
  $(modPop).appendTo('body');
  $("#diaCom").dialog({
      resizable: false,
      draggable: false,
      height:150,
      width:300,
      modal: true,
      buttons: {
          "Ok": function() {  
              def.resolve();
              $(this).dialog("close");
  
          },
          "Cancel": function() {
              def.reject();
              $(this).dialog("close");
  
          }
      }
  });
  
  return def.promise();
  }
  //on click
  if (validateField() == true){
          //do something
   }else{
          //do something
    }
  </code></pre>
  
  <p>hi everyone, any chance to return the value? I wish to return the true and false through showDialog().done() and fail for validatefield() function,  but it not working as what I want, I can't assign to bAllow as I had already have a return false to hold the dialog to execute its next line, any idea? Or it is correct to do like these?</p>