I have a table which is populated with details of jobs a user is looking for. The structure is akin to this:
<div class="container">
<table class="table-responsive table-hover table-bordered col-sm-12 col-md-6 col-md-offset-1 col-lg-6 col-lg-offset-1" id="resultsTable" border="0" cellspacing="0" cellpadding="0"><tbody>
<tr class="selectable selected">
<td class="summary">A Summary</td>
</tr>
<tr>
<td class="detail" id="32113607" style="display: table-cell;">This is some detail</td>
</tr>
<!-- And so on ....................... -->
</tbody></table>
</div>
I then have a function that handles the expand and retraction of the table rows.
$(function () {
//When clicking a row in the table, hide the other rows...
$("#resultsTable").on('click', '.selectable', function (e) {
$(this).addClass('selected').siblings().removeClass('selected');
$(this).siblings().children("td.detail").slideUp();
$(this).next("tr").children("td.detail").slideDown();
});
});
There's also some basic CSS, but nothing major. This is all in a fiddle here: http://jsfiddle.net/v9ec3/1176/
The strange thing is, if you start at the bottom and work upwards, it doesn't have any problems. If you start at the top and work down, it will jump partway through one of the records.
Having stepped through this in the dev tools, it looks like jQuery is trying to help in moving to offset the slide.
I have tried:
- e.preventDefault()
- e.stopPropogation()
- setting width/height
- setting overflow-y
- animations (i.e. going to id x)
- CSS transitions