2015-05-30 52 views
0

如果我为jQuery Tablesorter采取任何简单的例子并在本地运行,它可以正常工作。如果我将jquery-latest的本地链接替换为jquery 2.1.3的cdn链接,就好像jQuery尚未加载。所有你需要做的就是用
"cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"替换这个“<script type="text/javascript" src="./js/jquery-latest.js"></script>”中的src,这就像jQuery没有加载。例如,在Tablesorter的“寻呼机”演示代码:tablesorter.com/docs/example-pager.htmljQuery Tablesorter with jQuery 2.x

我是否缺少一些愚蠢的,明显的,令人尴尬的问题,或者Tablesorter不能与最新的jQuery,或...?

+0

请提供一些示例代码;这是更容易排除故障 – nomistic

+0

我是新来张贴在这里。当我试图将代码复制到textarea中时,它编辑了任何看起来像html的东西。 –

+0

如果你想粘贴代码,要么敲击空格键4次,要么选择整个代码块,然后使用ctrl-K – nomistic

回答

1

如果你看一下开发控制台(按F12),你会看到有一个JavaScript错误 - 使用jQuery V1.9 +当尝试在this demo

Uncaught TypeError: Cannot read property 'msie' of undefined

此错误仅出现。这是因为寻呼机代码使用插件的内部clearTableBody函数,该函数检查jQuery.browser是否为IE,并且因为该函数在jQuery v1.9 +中完全删除,所以会发生javascript错误。

所以你有三个选择。

  1. 切换到始终使用jQuery小于v1.9。
  2. Modify the core plugin和替换此代码:这个

    this.clearTableBody = function (table) { 
        $(table.tBodies[0]).empty(); 
    }; 
    
  3. this.clearTableBody = function (table) { 
        if ($.browser.msie) { 
         while (table.tBodies[0].firstChild) { 
          table.tBodies[0].removeChild(table.tBodies[0].firstChild); 
         } 
        } else { 
         table.tBodies[0].innerHTML = ""; 
        } 
    }; 
    

    或者,尝试了我fork of tablesorter不使用jQuery.browser,并且具有一系列增强功能,有用的部件和解析器。令人遗憾的是,大多数小部件与原始tablesorter不兼容。

+0

哇。感谢你花了这么多时间帮助新手。非常感谢。 –