tablesorter – How can I combine custom filter functions, custom selectSource and dynamic table population?

I’m trying to combine the approach from this answer for adding a custom filter option for selecting empty cells with a table which is populated dynamically. Unfortunately I’m finding that after an update to the content of the table, the dropdown is not being repopulated with the updated options from the data.

I’ve created an example here which illustrates the problem. Initially the table contains just 3 rows and the filter dropdown for the first column correctly shows those options, along with the “(Empty)” option for filtering down to just the empty rows.

After clicking the button which adds a bit more data to the table, the filter dropdown for the “Custom” should now contain the additional options (“biscuit” and “sausages”) along with those which existed before – like the “Default” column does. Unfortunately that doesn’t happen.


    theme: "default",
    widgets: ("filter"),

    widgetOptions: {
      filter_functions: {
        1: { '(Empty)': function(e, n, f, i, $r, c) { return $.trim(n) === ''; } }
      filter_selectSource: {
        1: function(table, column, onlyAvail) {
            var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
            return array;
    // Pretend this is actually data loaded using AJAX or whatever
    $("#tblsort tbody").append("<tr><td>4</td><td>Biscuit</td><td>Biscuit</td></tr>");
    $("#tblsort tbody").append("<tr><td>5</td><td></td><td></td></tr>");
    $("#tblsort tbody").append("<tr><td>6</td><td>Sausages</td><td>Sausages</td></tr>");
    $("#tblsort").trigger("update", (true));

<script src=""></script>
<link href="" rel="stylesheet"/>
<script src=""></script>
<script src=""></script>

<table id="tblsort">
    <th class="filter-false">#</th>
    <th class="filter-select" data-placeholder="(All)">Custom</th>
    <th class="filter-select" data-placeholder="(All)">Default</th>

<button id="addbtn">Add more data</button>

This clearly seems to be some sort of behavioural conflict between the custom filtering and the call to update the table after the new data has been added. But I can’t for the life of me work out how to solve it.