I have a library that build UI using Javascript, and because of the dynamic content involved I sometimes want to put content out to the browser, examine how the layout was c
We encountered a crazy problem with IE8 (Firefox, Chrome are fine). We use toggleClass('enoMyAddressesHide') on child element.
.enoMyAddressesHide{display:none}
But the parent(s) div container does not refresh/re-layout its height.
setTimeout(), read position, read width and height of element do not help. Finally we can find out a working solution:
jQuery(document).ready(function ($) {
var RefreshIE8Layout = function () {
$('.enoAddressBook:first').css('height', 'auto');
var height = $('.enoAddressBook:first').height();
$('.enoAddressBook:first').css('height', height);
};
$(".enoRowAddressInfo .enoRowAddressInfoArea ul li img.enoMyAddresses").click(function () {
$(this).parent().find(".enoAllInfoInAddressBox,img.enoMyAddresses").toggleClass('enoMyAddressesHide');
RefreshIE8Layout(); // fix IE8 bug, not refresh the DOM dimension after using jQuery to manipulate DOM
});
});
It looks stupid, but it works!