title: jQuery UI Dialog OnBeforeUnload
body: <p>I have a small problem.  I'm attempting to catch the OnUnLoad Event of the Window and ask a confirmation question and if the user decides they want to stay then fine, and if they want to leave the page then they'll lose all unsaved data.  Here's the issues...</p>
  
  <p>I'm using a jQuery UI Dialog and when I put the following code on my page, I have the Dialog open, and when I click the back button on the browser, it never pops up the msgbox.  It just refreshes the page:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
      $(window).bind('beforeunload', function() { 
              alert('you are an idiot!'); 
          } 
      );
  &lt;/script&gt;
  </code></pre>
  
  <p>And the solution that I'm using was a post <a href="https://stackoverflow.com/questions/276660/how-can-i-override-the-onbeforeunload-dialog-and-replace-it-with-my-own">here</a>.  Again, the msgbox will display fine if I do not have the jQuery UI Dialog open.  If I do, then it doesn't display the msgbox and just refreshes the page.</p>
  
  <p>Any ideas?</p>