jQuery tablesorter - loss of functionality after AJAX call

后端 未结 8 990
庸人自扰
庸人自扰 2021-02-14 06:00

I have recently been experimenting with the tablesorter plugin for jQuery. I have successfully got it up and running in once instance, and am very impressed. However, I have tri

8条回答
  •  执笔经年
    2021-02-14 06:32

    I was having the same problem except I was loading a table that had a row for every 'category' then inserting the data for every category into the table using asynchronous calls. Calling $("#myTable").tablesorter(..) after each record was returned caused my browser to bomb when more than a trivial number of records were loaded.

    My solution was to declare two variables, totalRecords and fetchedRecords. In the $(document).ready() I set the totalRecords to $("#recordRows").length; and every time I populate a record in the table, the fetchedRecords variable is incremented and if fetchedRecords >= totalRecords then I call $("#myTable").tableSorter(..).

    Works quite well for me. Of course, your mileage may vary.

提交回复
热议问题