The solution from Robert MacLean with highest number of votes is 99% correct. But the only addition someone might require, as I did, is whenever you need to open up this jQuery dialog, do not forget to append it to parent. Like below:
var dlg = $('#questionPopup').dialog( 'open');
dlg.parent().appendTo($("form:first"));