我想在jQuery中定位一個對話框,並且我有以下代碼。它似乎沒有做我期望的事情。我只需要將對話框設置爲居中或出現在身體的左上角。定位對話框
這裏是我的代碼有
agreeDialog = $j('#termsOfAgreementConfirm').dialog({
modal: true,
autoOpen:false,
resizable:false,
width : 1000,
height :400,
stack:false,
closeOnEscape:false,
title:"Terms of Usage",
open: function(event, ui) {
$j('.ui-dialog-titlebar-close').hide();
},
buttons: {
Disagree: function() {
disagree.dialog('open');
disagree.dialog('moveToTop');
},
Agree: function() {
$j(this).dialog('close');
$j.cookie("agree", "Y");
new Ajax.Request('/myballback/user/ajaxUpdateAgreementForUser',
{
onSuccess:function(resp) {
},
onError: function(resp) {
alert("Error:" + resp.toJSON());
return;
},
asynchronous:true,
evalScripts:true
});
$j(this).dialog('close');
}
}
});
var x = jQuery(agreeDialog).position().left + jQuery(agreeDialog).outerWidth();
var y = jQuery(agreeDialog).position().top - jQuery(document).scrollTop(); //agreeDialog.dialog({width:width, height:height ,position:[posX, posY]});
agreeDialog.dialog('option', 'position',[x, y]);
當我做了左上角。它所做的是移動對話框,但將它移動到瀏覽器窗口的左邊緣,但對話框仍位於頁面的底部。我的div在對話中的定義方式和位置有什麼關係? – allthenutsandbolts 2011-12-15 20:43:53
你自己的CSS規則是否對``div``起作用? – jabclab 2011-12-15 20:47:48