The $('#dialog').parent().appendTo($("form:first"))
solution works fine in IE 9. But in IE 8 it makes the dialog appear and disappear directly. You can't see this unless you place some alerts so it seems that the dialog never appears.
I spend one morning finding a solution that works on both versions and the only solution that works on both versions 8 and 9 is:
$(".ui-dialog").prependTo("form");
Hope this helps others that are struggeling with the same issue