Using jQuery tableSorter on dynamically modified table

前端 未结 4 1530
眼角桃花
眼角桃花 2020-12-09 09:17

I am using the jQuery tableSorter plugin on a page.

Unfortunatley, the table that is being sorted is dynamically modified, and when I sort after adding an element, t

4条回答
  •  有刺的猬
    2020-12-09 09:58

    The $(table).trigger("update"); throws error

        Uncaught TypeError: Cannot read property 'rows' of undefined 
    

    So, there is a jquery function .ajaxStop() where tablesorter() is called. Do not call tablesorter in .ready()

        jQuery(document).ajaxStop(function(){
          jQuery("#table_name").tablesorter();
        })
    

    which did the job

提交回复
热议问题