title: Stop function until clicked ok or cancel - JQUERY
body: <p>i created custom confirm box like this:</p>
  
  <pre><code>function formPopup(message, callback) {
      message = message + '&lt;div class="clear"&gt;&lt;/div&gt;&lt;button class="mybutton" name="check" value="true"&gt;Yes&lt;/button&gt;' +
              '&lt;button class="mybutton mybutton2" name="check" value="false"&gt;No&lt;/button&gt;';
      createPopup("Message", message);
  
      $(".popup .body button[name='check']").bind("click", function (e) {
          val = $(this).val();
          if (val == "true") {
              $(".popup").find(".close").trigger("click");
              typeof (callback) != "undefined" ? callback() : null;
          } else {
              $(".popup").find(".close").trigger("click");
          }
      });
  }
  </code></pre>
  
  <p>i want when i run formPopup function the page wait like "confirm" or "alert" until i will click on <code>$(".popup .body button[name='check']")</code>.</p>
  
  <p>i tried with</p>
  
  <pre><code>promise and when
  </code></pre>
  
  <p>but its didnt helped.</p>
  
  <p>tnx a lot</p>