I’m trying to slideToggle a in a table with jQuery and it works in FF, OP, CHrome. Only IE (6,7,8) is giving me problems. It slides down perfectly down and up, but after the slide up animation is finished. The hidden pops up in full height and then closes.
So I guess it must be somwhere inbetween when it switches from a minimal height to “display:none” that it appears for a short second.
The code is built dynamically but I’ll try to give an example:
<table>
<tr>
<td>
<script type="text/javascript">
function toggleTr_{$dynamicID}() {
$('#content_{$dynamicID}').slideToggle('slow');
/* DO SOME OTHER STOFF LIKE COLOR CHANGES CSS CLASS CHANGES */
}
</script>
</td>
</tr>
<tr id="list_{$dynamicID}" onclick="toggleTr_{$dynamicID}();" style="cursor:pointer;">
<td> <!-- INFO HEADER --> </td>
</tr>
<tr>
<td>
<div id="content_{$dynamicID}" style="display:none;">
<!-- INFO BODY HIDDEN -->
</div
</td>
</tr>
Other problems here with slideToggle only descibed problems with padding, margin, or problems with the animation, but that all works.
Help is appreciated.
Thx, Spanky
I found a solution.
It seems that only jquery’s .slideUp() function is causing the problem when setting the height back to 0px. The bug only seems to appear when the browser is working in QuirksMode (HTML Transitional 4.01 DocType) and on IE. The solution I found here is a replacement for .slideUp(). So instead of
you write
Thx to Siderite Zackwehdex wo also reported the bug to jQuery (http://dev.jquery.com/ticket/5062), but they won’t fix it. They said:
I also found a fix, or replacement for .slideToggle() for everyone who doesn’t have the time or control over the HTML to fix it and make it “QuirksMode Clean”.
Here you’ll find an explanation and function that works like a charm. The only change I had to make, was setting the height to ‘1px’ so it won’t jump open on the first run of .slideToggle() if elements are hidden from the beginning on.
So my working solution finally looks like this: