title: jQuery UI: Show dialog that user must confirm or cancel
body: <p>I have a few links on my site that will need to show a modal dialog when the user clicks on one of them. The modal will contain a message like: <code>You are now leaving the "SECTION NAME" part of "SITE NAME"</code>. The user will then either accept which will allow the user to continue on with their request or cancel which will keep the user where they are.</p>
  
  <p>An example of a link would be: <code>&lt;a href="/interests" title="My Interests" target="_blank" class="leaving-section"&gt;My Interests&lt;/a&gt;</code></p>
  
  <p>So as you can see the class of <code>leaving-section</code> would cause the link to do what I have specified above, and will also open the link in a new tab/window BUT the user must first accept that they are aware they are being taken to another part of the site.</p>
  
  <p>I have looked at the docs but I haven't seen any examples where a) the dialog is created on the fly rather than hiding and showing a div and b) allowing the user to confirm and being sent to their original location i.e. the url which they clicked.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>$("#leaving-section").dialog({
              resizable: false,
              modal: true,
              buttons: {
                  "I understand, take me there": function () {
                      $(this).dialog("close");
                  },
                  "I want to stay where I am": function () {
                      $(this).dialog("close");
                  }
              }
          });
  
          $('.leaving-section').click(function (event)
          {
              event.preventDefault();
              var $dialog = $('#leaving-section');
              $dialog.dialog('open');
          });
  </code></pre>
  
  <p>But I want to the modal to be created by jquery instead of the div being embedded in the page! Also how do I get the first button to send them off to their original destination?</p>
  
  <p>Thanks to all who can help. Thanks</p>