views:

1256

answers:

2

In a web application I'm hitting some troubles with dynamic content - where by a form being hidden or shown above a jquery ui tab control causes rendering issues until the user hovers there mouse over the tabs, which then causes the tab header to redraw in the correct location.

It's only occuring in IE7 and as a quick hack I'm doing this after showing the form to cause the tab's div to be refreshed in IE:

$('#tabs').css('display', 'none').css('display', 'block');

I'm just wondering if there is a more appropriate/robust way to cause a div element to redraw itself / recalculate the layout of elements on a page, as I'm worried my approach may have unwanted side-effects on other browsers.

+4  A: 

Wild guess, but could be hasLayout.

Try adding something like:

#tabs {
  zoom: 1;
}
wombleton
Indeed. The evils of hasLayout will be repealed in IE8 standards mode, we are assured.
Dustman
I roll to disbelieve.
wombleton
I had a quick look and it appears the #tabs div already hasLayout=true ... though I'm going to try applying zoom: 1 to the dynamic form that's displayed above, which I believe does not currently have hasLayout=true.
Bittercoder
+1  A: 

I had a similar issue to this once, it turned out to be an issue with the width not being set on the displaying div. When I set the static px width on the element it worked.

bendewey
Yah, setting a width also sets hasLayout to true. http://www.satzansatz.de/cssd/onhavinglayout.html
wombleton
That's a good resource - though I've come across snippets of articles on hasLayout etc. - I've not seen that article which is very thorough.
Bittercoder