I was having some related issues, trying to insert a table row after the clicked row. All is fine except the .after() call does not work for the last row.
$('#traffic tbody').find('tr.trafficBody'trafficBody).filter(':nth-child(' + (column + 1) + ')').after(insertedhtml);
I landed up with a very untidy solution:
create the table as follows (id for each row):
<tr id="row1"> ... </tr>
<tr id="row2"> ... </tr>
<tr id="row3"> ... </tr>
.
.
.
etc ...
and then :
$('#traffic tbody').find('tr.trafficBody' + idx).after(html);