TableSorter Filter and scroller widget update

隐身守侯 提交于 2019-12-02 03:00:36

There are two issues.

  1. The filter widget does not initialize on an empty table.
  2. The scroller widget needs a lot of bug fixes (which I have not had time to do)
    • including adding the filter row if it was not present on initialization.
    • completely removing the scroller widget when updating the table
    • etc.

In order to work around this issue, try changing your append code to this (update demo):

$("#append").click(function () {
    // add some html
    var html = "<tr><td>Aaron</td><td>Johnson Sr</td><td>Atlanta</td><td>GA</td></tr>",
        // scroller makes a clone of the table before the original
        $table = $('table.update:last');

    // append new html to table body 
    $table.find("tbody").append(html);

    // remove scroller widget completely
    $table.closest('.tablesorter-scroller').find('.tablesorter-scroller-header').remove();
    $table
        .unwrap()
        .find('.tablesorter-filter-row').removeClass('hideme').end()
        .find('thead').show().css('visibility', 'visible');
    $table[0].config.isScrolling = false;

    // let the plugin know that we made a update, then the plugin will
    // automatically sort the table based on the header settings
    $("table.update").trigger("update");

    return false;
});

I'll try to patch up, bug fix and probably completely rewrite the scroller widget when I have time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!