Dialog div inside script

Dialog div inside script

I have a problem where I try to make a self contained script that will
show a dialog using jQuery UI dialog. Problem is, if I create the div
programatically (inside the script) the dialog never shows. Here is
the sample code I've got so far:
function showDialog(){
var theDiv = jQuery("<div id='DialogDiv' class='DialogDiv'>Hi
there</div>").appendTo("body");
var dialogOptions = {
autoOpen: false,
buttons: { "Ok": function(){ alert("hi");} },
height: 300,
modal: true,
title: "Properties"
}
var theDialog = theDiv.dialog(dialogOptions);
theDialog.dialog('show');
}
I know that the div I create is actually added to the web page, as it
shows temporarely when I step through the method using firebug.
Any suggestions will be greatly apreciated (espcially if they
work ;-) )
Thanks,
Jarnis
--