I have a jQuery dialog box that is meant to position in the middle of the screen. However, it seems slightly off-center vertically.
Here is the code:
None of the above solutions seemed to work for me since my code is dynamically generating two containting divs and within that an un-cached image. My solution was as follows:
Please note the 'load' call on img, and the 'close' parameter in the dialog call.
var div = jQuery('')
.attr({id: 'previewImage'})
.appendTo('body')
.hide();
var div2 = jQuery('')
.css({
maxWidth: parseInt(jQuery(window).width() *.80) + 'px'
, maxHeight: parseInt(jQuery(window).height() *.80) + 'px'
, overflow: 'auto'
})
.appendTo(div);
var img = jQuery('
')
.attr({'src': url})
.appendTo(div2)
.load(function() {
div.dialog({
'modal': true
, 'width': 'auto'
, close: function() {
div.remove();
}
});
});