I currently have a problem with the slideToggle() jQuery effect on a table row with a nested table.
I have the following HTML markup:
<table>
<tbody>
<tr>
<th>One</th>
<th>Two</th>
<th>Three</th>
</tr>
<tr class="show-details">
<td>Item1</td>
<td>Item2</td>
<td>Item3</td>
</tr>
<tr class="details">
<td colspan="3">
<table>
<tbody>
<tr>
<td>Lorem Ipsum</td>
<td>Ipsum Lorem</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="show-details">
<td>Item1</td>
<td>Item2</td>
<td>Item3</td>
</tr>
<tr class="details">
<td colspan="3">
<table>
<tbody>
<tr>
<td>Lorem Ipsum</td>
<td>Ipsum Lorem</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
I want to hide the detail row right away and show it with the slideToggle() function. I have the following jQuery code:
$(function() {
$(".details").hide();
$('.show-details').click(function(e){
$(this).next(".details").slideToggle(500);
$("td > span", this).toggleClass('open')
});
});
The problem is that the row goes from display:none; to display:table-row; which results in a display:none;
to display:block;
to display:table-row;
. The effect then jumps to display block, then animates the height of the row (+ overflow it by a ton, so the next row jumps down for a few secs) and then at last turn into display:table-row;
when the animation is over.
Any suggestions to get the effect working with a simple slideToggle to display the .detail
row?
I've tried the answers in this question without any luck.