How to get a return value from a popup

How to get a return value from a popup

PLEASE DON'T SEND ME LINKS TO DIALOG TUTORIALS, THAT'S NOT WHAT I WANT!

This should be a rather simple question. I create a popup and that popup acts as a confirmation box WITH options (which is why confirm() isn't applicable).

Essentially this is a form within a popup and the 'X' acts as a cancel operation (which returns a FALSE), and the "OK" button acts as a submit which returns TRUE when pressed.

  1. <a href="#popupConfirm" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all">Show Popup</a>
  2. <div data-role="popup" id="popupConfirm" data-theme="b" data-history="false" data-dismissible="false">
  3.   <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
  4.   <p>I have a close button at the top right corner.</p>
  5.   <p><a href="#" onclick="$( "#popupConfirm" ).popup( "close" ); return(TRUE);" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">Send Now!</a></p>
  6. </div>
So, my question is how do I detect when the 'X' is pressed and/or does that automatically bubble up as a 'FALSE' return? What happens to the submit, is that returned as a TRUE? And the settings within the form?

Sorry but the popup docs are just not clear about that.

Thanks!

P.