I am loading a MODAL that is fed an image that I get and load on click. Can someone please explain how to load and then display my image on click so that the dialog will center itself properly. As it stands, the Dialog doesn't know the image size so it is loading off center. I tried using the .load function but I don't know where to put it; because it gave me errors. The below code is fully functional but I need it to pre-load desIMG before I feed it to the dialog so it knows the size.
function thumbNailModal() {
$('.thumb').click(function() {
picDES = document.getElementById(this.id).getAttribute('id');
var desIMG = $('<img/>', {
"class":"inline",
src: '/images/design/full/' + picDES
});
$(desIMG).dialog(
{
modal: true,
draggable: false,
title: 'Designs',
height: 'auto',
width: 'auto',
open: function(){
jQuery('.ui-widget-overlay').bind('click',function(){
jQuery(desIMG).dialog('close');
})
}
}
);
$(".ui-dialog-titlebar").hide();
});
}
EDIT
function thumbNailModal() {
$('.thumb').click(function() {
.load(
picDES = document.getElementById(this.id).getAttribute('id');
var desIMG = $('<img/>', {
"class":"inline",
src: '/images/design/full/' + picDES
});
)
I want something more like that. Where you click and THEN it loads. Not just preloading all the images as soon as you load the page.