我无法更改 jQuery-ui 对话框的位置。
我正在做的是将图像加载到打开事件中的对话框中。由于图像的高度未知,对话框不再居中在窗口中。所以我也在加载图像后重新定位它,但重新定位似乎被忽略了。
但是,如果我在重新定位之前添加一个警报,它工作正常,所以很明显某种时间问题在这里发挥作用。
有什么解决方法吗?
我的代码的相关位是:
$( "#dialog-message" ).dialog({
open: function(e, ui){
$("#theImage").attr("src","aRandomImage.jpg");
alert(1); // causes the next line to work properly
$(this).dialog("option", "position", {my: "center", at: "center", of: window});
},
...