2014-02-22 118 views
1

好了,我看可以在文档上的入门例子:http://mottie.github.io/tablesorter/docs/index.html#Demo为什么不能正确加载?

我尝试做文档中提供的基本的例子,但是我的表不符合的tablesorter功能加载(即标题上的排序图标或可点击的标题列),如在线版本所示。我做错了什么?...

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="UTF-8"> 
     <title>Something</title> 
     <!-- load tableSorter theme --> 
     <link href="http://mottie.github.io/tablesorter/css/theme.default.css" rel="stylesheet"> 
     <!-- load jQuery and tableSorter scripts --> 
     <script type="text/javascript" src="./includes//jquery-2.1.0.js"></script> 
     <script type="text/javascript" src="./includes/tablesorter-master/js/jquery.tablesorter.js"></script> 
     <!-- load tableSorter widgets --> 
     <script type="text/javascript" src="./includes/tablesorter-master/js/jquery.tablesorter.widgets.js"></script> 
     <script type="text/javascropt"> 
     $(document).ready(function(){ 
      $("table").tablesorter({ 
       theme : 'blue', 
       widgets : ['zebra','columns'], 
       sortList: [[0,0]], 
       debug : true, 
       widthFixed: false, 
       showProcessing : true 
      }); 
     }); 
     </script> 
</head> 
    <body> 
     <table class="tablesorter"> 
      <thead> 
       <tr> 
        <th>Last Name</th> 
        <th>First Name</th> 
        <th>Email</th> 
        <th>Due</th> 
        <th>Web Site</th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr> 
        <td>Smith</td> 
        <td>John</td> 
        <td>[email protected]</td> 
        <td>$50.00</td> 
        <td>http://www.jsmith.com</td> 
       </tr> 
       <tr> 
        <td>Bach</td> 
        <td>Frank</td> 
        <td>[email protected]</td> 
        <td>$50.00</td> 
        <td>http://www.frank.com</td> 
       </tr> 
       <tr> 
        <td>Doe</td> 
        <td>Jason</td> 
        <td>[email protected]</td> 
        <td>$100.00</td> 
        <td>http://www.jdoe.com</td> 
       </tr> 
       <tr> 
        <td>Conway</td> 
        <td>Tim</td> 
        <td>[email protected]</td> 
        <td>$50.00</td> 
        <td>http://www.timconway.com</td> 
       </tr> 
      </tbody> 
     </table> 
    </body> 
</html> 

回答

0

它看起来像主题选项没有被设置。当你初始化的tablesorter不带任何选项:

$("#myTable").tablesorter(); 

“默认”的主题设定,所以一定要包括“theme.default.css”文件;但因为它看起来像您所加载的“蓝色”主题样式,初始化插件如下:

<script type="text/javascropt"> 
$(function(){ 
    $("#myTable").tablesorter({ 
     theme: "blue" 
    }); 
}); 
</script> 

现在,从望着蔚蓝的主题文件名,看来,它可能是原来的蓝色主题的意思为tablesorter v2.0.5(“/blue/style.css”)。我敢冒险猜测这里使用的tablesorter来自我的fork of tablesorter,所以请确保加载名为"theme.default.css"的文件。

+0

Mottie!感谢您指出我的错误。但是,这仍然不能解决问题。我已经编辑了我的代码供您阅读。我现在的问题是没有格式化发生,就好像tablesorter没有识别表格一样。我已删除表格“ID”,FYI。是的,我正在使用叉子。 –

+0

那么现在这个插件正在初始化'$(“mytable”)'......它需要一个前面的'#'来使选择器变成一个ID或'.'作为类名,这两个都不会出现在HTML。 – Mottie

+0

不,道歉是编辑(编辑)我忘了改变,如果你让我。我现在修改了它,可以确认它是'$(document).ready(function(){$('table')。tablesorter({...'在我的实际代码中,我也有'theme:'选项。蓝色',''设置在其他选项之前。仍然没有。 –

相关问题