i have table and after updating it by JS i run update trigger (like it was said a lot of times in such cases) but it doesn’t working and FireBug says: “TypeError: s[1] is undefined”.
// in $(document).ready()
$('#stattable').tablesorter();
// after updating table content
$('#stattable').triggerHandler('update');
$('#stattable').trigger('sorton', [[1, 1], [0, 0]]);
$('#stattable').trigger('appendCache');
HTML code:
<table id="stattable">
<thead>
<tr><th>Producer</th><th>Value</th><th>Amount</th></tr>
</thead>
<tbody>
<!-- here dynamically generated data -->
</tbody>
<tfoot>
<tr><td>SUM:</td><td></td><td></td></tr>
</tfoot>
</table>
Dynamic data is in format:
<tr>
<td>Ford</td>
<td>1999.90</td>
<td>10</td>
</tr>
<tr>
<td>Renault</td>
<td>345.1</td>
<td>2</td>
</tr>
<tr>
<td>Mitsubishi</td>
<td>0</td>
<td>0</td>
</tr>
... etc.
Any ideas?
When you trigger an event, you need to wrap the extra parameters in square brackets:
So in this case, the sortList is missing an extra set of brackets: