Bug Tracker

Opened 15 years ago

Closed 15 years ago

#1787 closed bug (fixed)

Dialog centering on div creation

Reported by: elmkneely Owned by: rworth
Priority: major Milestone: 1.2.2
Component: ui Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:

Description

It looks like the issue I found with not centering on scrolling has been resolved (ticket 1703). However, I couldn't find anyplace where it looked like another issue I have found has been noted or addressed. The issue occurs when trying to set 'position': 'center' on a dialog where you use the $('<div></div>') method of creating the dialog dynamically. Specifically, if you try to get the height/width of uiDialog prior to appending the element to the body, the height and width of uiDialog will be 0 and you won't get a true centering. Here is how I addressed both of these issues in this.open of ui.dialog:

this.open = function() {

var wnd = $(window), top = 0, left = 0;

uiDialog.appendTo('body');

switch (options.position) {

case 'center':

top = (wnd.height() / 2) - (uiDialog.height() / 2) + wnd.scrollTop();

left = (wnd.width() / 2) - (uiDialog.width() / 2) + wnd.scrollLeft();

break;

case 'left':

top = (wnd.height() / 2) - (uiDialog.height() / 2) + wnd.scrollTop();

left = 0;

break;

case 'top':

top = 0;

left = (wnd.width() / 2) - (uiDialog.width() / 2) + wnd.scrollLeft();

break;

}

uiDialog.css({top: top, left: left});

uiDialog.show();

};

Change History (2)

comment:1 Changed 15 years ago by rworth

Owner: set to rworth
Status: newassigned

comment:2 Changed 15 years ago by rworth

Resolution: fixed
Status: assignedclosed

Fixed in rev3726

Note: See TracTickets for help on using tickets.