title: How to prevent leaving the page until answer accepted from jquery ui dialog
body: <p>I have this code:</p>
  
  <pre><code>$(window).bind('beforeunload', function () {
  
          $("#dialogsendnotifications").dialog('open');
      });
  
      $("#dialogsendnotifications").dialog({
  
          autoOpen: false,
          closeOnEscape: false,
          buttons: {
              "Yes": function () {
                  $(this).dialog('close');
              },
              "No": function () {
                  $(this).dialog('close');
              }
          }
      });
  </code></pre>
  
  <p>So basically what it does is when the user tries to navigate away it pops up the yes no dialog. The troub is that the dialog comes up but it navigates away from the page before the user even gets to choose a button.</p>
  
  <p>Can someone please tell me how to get it to wait until the user has selected an answer?</p>