Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery tablesorter pager plugin doesn't work properly with IE11 in Edge mode

If you are using the Tablesorter Jquery plugin with the pager add on the table will not display any of the data. The data is there but it is hidden.

I suspect the browser feature detection method of the plugin can't handle IE11.

Anyone else run into this?

like image 630
John S Avatar asked Oct 21 '13 20:10

John S


2 Answers

It seems that IE11 have a problem with his userAgent. A turnaround is to change clearTableBody function (working in jquery.tablesorter-2.0.3.js) like this :

this.clearTableBody = function (table) {
    //if ($.browser.msie) {
        function empty() {
            while (this.firstChild) this.removeChild(this.firstChild);
        }
        empty.apply(table.tBodies[0]);
    //} else {
    //    table.tBodies[0].innerHTML = "";
    //}
};
like image 189
Pierre-Yves CUGNIET Avatar answered Oct 03 '22 04:10

Pierre-Yves CUGNIET


This is in a way due to Internet Explorer 11 having a user agent string that doesn't include "MSIE", so jQuery doesn't identify it properly (see this question).

But really, the TableSorter Pager code doesn't need to know which browser is running the code. Change the function clearTableBody to leverage jQuery's cross-browser implementation instead:

this.clearTableBody = function(table) {
    $(table.tBodies[0]).empty();
};

I have tested this in IE8, IE9, IE11, Chrome 31 and Firefox 24.

(And just now, I found a GitHub repo with a fork of TableSorter that has possibly fixed this already: https://github.com/Mottie/tablesorter)

like image 24
Christian Davén Avatar answered Oct 03 '22 03:10

Christian Davén