Can jQuery dialog be used in place of a javascript confirm?

Can jQuery dialog be used in place of a javascript confirm?

I can not figure out how to replace a javascript confirm with a jQuery dialog.  I can attach it to my links, but when the user clicks Yes, I don't know how to find the link that initiated the action and how to continue the click event so it works universally for href and onclick.  Thoughts?

  1. <html>
  2. <head>
  3. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  4. <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script>
  5. <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css" type="text/css" media="all" />
  6. </head>
  7. <body>
  8. <a href="http://www.google.com">google</a><br />
  9. <a href="#" onclick="document.location.href='http://www.yahoo.com';return false;">yahoo</a><br />
  10. <a href="#" onclick="if( confirm('do it?') ) document.location.href='http://www.dogpile.com';return false;">dogpile</a><br />
  11. <div id="warning" style="display: none;">Do the link?</div>
  12. <script>
  13. $().ready(function(){
  14. $('#warning').dialog({
  15.       modal: true,
  16.       autoOpen: false,
  17.       width: 500,
  18.       buttons: {
  19.            'Yes': function() { $(this).dialog('close') },
  20.            'No': function() { $(this).dialog('close') }
  21.       }
  22.     });
  23. });
  24. $('a').click(function(event){
  25.      $('#warning').dialog('open');
  26.    event.preventDefault();
  27. });
  28. </script>
  29. </body>
  30. </html>