Skip to content Skip to sidebar Skip to footer

How Do I Pass A An Element Position To Jquery UI Dialog

I have a list of elements and when clicking on each one I would like my jQueryUI dialog box to pop up next to the list element that was clicked on. $( '#selector' ).dialog({ dragga

Solution 1:

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");
});

Solution 2:

Before showing the dialog again, try:

$("#selector").dialog("option", "position", [e.pageX, e.pageY]);

Post a Comment for "How Do I Pass A An Element Position To Jquery UI Dialog"