In a nutshell I want a callback to fire after the html has been injected and the content of that html has rendered. Reason being I need to know the height of the new content right away. Something like this:
$('div').html(tonsofstuff);
console.log( $('div').height() ); //works in Firefox, but returns 0 in Chrome
setTimeout(function(){
console.log( $('div').height() ); //works everywhere, but takes too long
},3000);
The issue is occasionally in some browsers (and always in chrome) $('div').height() fires before the new content has a height.
My fantasy:
$('div').html(tonsofstuff, function(){
console.log( $('div').height() );
});
or even
$('div').html(tonsofstuff).load(function(){
console.log( $('div').height() );
});
This is what I do:
var height = $('div').html(tonsofstuff).height();
I never had any problems with waiting for it to render.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With