且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将元素位置传递给jquery UI对话框

更新时间:2023-10-24 23:22:52

由于您想要显示单击元素旁边的对话框,您应该推迟设置对话框的位置,直到该信息可用,即在您的事件处理程序中:

Since you want to show the dialog next to the clicked element, you should defer setting the dialog's position until that information becomes available, i.e. in your event handler:

$("#selector").dialog({
    draggable: false,
    width: 250,
    autoOpen: false
});

$(".openDialog").click(function(e) {
    $("#selector").dialog("option", "position", [e.pageX, e.pageY])
                  .dialog("open");
});