Get the button clicked in a dialog

Get the button clicked in a dialog

I already saw on google and on the forum, but really can't believe there isn't something like:
  1. var a = $('#dialog').dialog('open');
that gives back the button clicked. Must i have a callback to another function? This behaviour is really weird, because the most obvious thing is that i want the script to continue running *after* the user clicked on something, not "later in another function".

Isn't there something to do that?

Thank you in advance.