views:

38

answers:

3

I have a jquery dialog box that loads with an image and auto resizes to the image. This is what I want. However, the box is rendered at the center position, but the image isnt fully loaded yet, there is a delay in getting the image. So when the image is loaded into the dialog box the upper left corner is centered, but the whole bottom right extends further down and right sort of skewed to the side. I know this is because the box renders and then is changed because of the image. How can I go about centering this box after it loads the image?

A: 

I think the real issue here is that the dialog box is position:fixed. Depending on the dialog boxes margin sizes you might not have enough real estate to display the full image in the dialog box.

Still this is only speculation. Can you provide an example, maybe on http://jsfiddle.net/ if you can't show the actual site.

Antilogic
function showMyDialog(imageURL) { $('#<%= this.theImage.ClientID %>').attr('src', imageURL); $('#<%= this.theDialog.ClientID %>').dialog('open'); }I tried doing the $( ".selector" ).dialog( "option", "position", 'center' ); and it hasn't worked. I just need ideas on a way to position this box after it loads.
Tom
+2  A: 

Have you tried to set the position once the image is fully loaded ?

$( ".selector" ).dialog( "option", "position", 'center' );
Golmote
A: 

What you should do is load the image first then once the image is loaded open the dialog use the load event to determine when to when to open the dialog

mcgrailm