在Edge模式下,JQuery tablesorter pager插件无法与IE11一起正常工作

Joh*_*n S 19 jquery internet-explorer jquery-ui internet-explorer-11

如果您使用Tablesorter Jquery插件与页面上的分页器添加将不会显示任何数据.数据在那里,但它是隐藏的.

我怀疑该插件的浏览器功能检测方法无法处理IE11.

其他人遇到这个?

小智 28

IE11似乎与他的userAgent有问题.一个转变是改变clearTableBody函数(在jquery.tablesorter-2.0.3.js中工作),如下所示:

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 = "";
    //}
};
Run Code Online (Sandbox Code Playgroud)


Chr*_*vén 20

这是因为Internet Explorer 11具有不包含"MSIE"的用户代理字符串,因此jQuery无法正确识别它(请参阅此问题).

但实际上,TableSorter 呼叫器代码不需要知道哪个浏览器正在运行代码.更改函数clearTableBody以利用jQuery的跨浏览器实现:

this.clearTableBody = function(table) {
    $(table.tBodies[0]).empty();
};
Run Code Online (Sandbox Code Playgroud)

我在IE8,IE9,IE11,Chrome 31和Firefox 24中测试了这个.

(刚才,我发现了一个带有TableSorter分支的GitHub仓库,可能已经解决了这个问题:https://github.com/Mottie/tablesorter)