The script below loads content into a lightbox window.
I am trying to figure out how to calculate the height of the box after the content is loaded into it.
It currently is finding the height prior to loading causing a problem with the vertical centering
Here is the page:
One Equity Partners :: All Companies
Thank You E
$('.more_info').click(function(){
popout="<div id='lightbox_pop_out'></div>";
lightbox="<div id='lightbox'></div>";
$('body').prepend(popout+lightbox);
popout_id=$(this).find('a').attr('id');
$.ajax({
type: "POST",
url: "/application/view/content/portfolio_pop_up.php?portfolio="+popout_id,
data: "name=John&location=Boston",
success: function(msg){
$('#lightbox_pop_out').append(msg);
}
});
$("body").css("overflow", "hidden");
//center lightbox
w=$(window).width();
h=$(window).height();
lw=$('#lightbox_pop_out').width();
lh=$('#lightbox_pop_out').height();
if(lh<h){ ptop=(h-lh)/2; }
else { ptop=10; }
left=(w-lw)/2;
console.log(lh);
$('#lightbox_pop_out').css({'top':ptop,'left':left+'px'});
$('#lightbox_pop_out').fadeIn('fast');
return false;
});