我正在成功打开一个JQuery对话框模式。我的第一个JQuery函数打开对话框,我的第二个jquery函数将对话框位置设置为top。我想合并这两个函数,请看下面的代码: -
$(function () {
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true
});
$('#modal-registration').dialog({ position: 'top' });
});
在上面的代码中,如何将$("#modal-registration").dialog({autoOpen:false, et:cetera})
和$('#modal-registration').dialog({ position: 'top' });
这两个函数相互合并?,谢谢。
答案 0 :(得分:1)
你能不能在第一次对话调用时坚持使用position属性?像
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position: 'top'
});
答案 1 :(得分:0)
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position: 'top'
})
为什么不用单一命令?
答案 2 :(得分:0)
<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title">I'm a dialog</div>
$('#dialog').dialog( 'option', 'position', [0, 0] );
将[0,0]更改为您需要的x,y坐标
答案 3 :(得分:0)
根据您的小提琴链接,您可以执行以下操作:
$( "#dialog" ).dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position : [0,0] //mention the attribute here itself
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
工作正常。