2017-04-24 471 views
0

我不能贊同的tablesorter之一,因爲它拋出一個錯誤使用tooltipster庫:

Uncaught TypeError: $(...).tooltipster is not a function

而且我的代碼:

<html><head> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> 
<script type="text/javascript" src="llibreries/tooltipster/dist/js/tooltipster.bundle.min.js"></script> 
<link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" /> 
<link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" /> 
<link rel="stylesheet" href="css/vista.css" type="text/css" /> 
<link rel="stylesheet" type="text/css" href="llibreries/tooltipster/dist/css/tooltipster.bundle.min.css" /> 

<script type="text/javascript"> 
     $(document).ready(function() { 
       $('.tooltip').tooltipster({ 
     contentCloning: false 
     }); 
     }); 
</script> 

<script type="text/javascript" src="llibreries/jquery-latest.js"></script> 
<script type="text/javascript" src="llibreries/jquery.tablesorter.js"></script> 
<script type="text/javascript" src="js/docs.js"></script> 
<script type="text/javascript" src="addons/pager/jquery.tablesorter.pager.js"></script> 

    <script type="text/javascript"> 
     $(function() 
    { 
       $("table") 
       .tablesorter({widthFixed: true, widgets: ['zebra']}) 
       .tablesorterPager({container: $("#pager") 
    }); 
    }); 
    </script></head> .... 

如果我評論第二個腳本$(「table」)。tablesorter ...工具提示腳本起作用。否則,它不會。不能使它工作,我做錯了什麼?

+6

不要包含jQuery兩次。這是個問題。 – dfsq

+1

同意。拿出第二個jQuery參考,然後再試一次。包括它兩次幾乎總是會導致問題。 – ADyson

回答

1

請檢查嵌入在頭

請檢查鏈接CDN for the Tooltipster爲CDN的鏈接。

這是錯誤的

<script type="text/javascript" src="llibreries/tooltipster/dist/js/tooltipster.bundle.min.js"></script> 
<link rel="stylesheet" type="text/css" href="llibreries/tooltipster/dist/css/tooltipster.bundle.min.css" /> 

試試這個

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.js"></script> 

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" /> 

<html><head> 
 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> 
 
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.js"></script> 
 
<link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" /> 
 
<link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" /> 
 
<link rel="stylesheet" href="css/vista.css" type="text/css" /> 
 
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" /> 
 

 
<script type="text/javascript"> 
 
     $(document).ready(function() { 
 
       $('.tooltip').tooltipster({ 
 
     contentCloning: false 
 
     }); 
 
     }); 
 
</script> 
 

 
<script type="text/javascript" src="llibreries/jquery-latest.js"></script> 
 
<script type="text/javascript" src="llibreries/jquery.tablesorter.js"></script> 
 
<script type="text/javascript" src="js/docs.js"></script> 
 
<script type="text/javascript" src="addons/pager/jquery.tablesorter.pager.js"></script> 
 

 
    <script type="text/javascript"> 
 
     $(function() 
 
    { 
 
       $("table") 
 
       .tablesorter({widthFixed: true, widgets: ['zebra']}) 
 
       .tablesorterPager({container: $("#pager") 
 
    }); 
 
    }); 
 
    </script></head> 
 
    <body> 
 
    </body> 
 
    </html>

$(document).ready(function() { 
 
    $('.tooltip').tooltipster({ 
 
    contentCloning: false 
 
    }); 
 
});
<html><head> 
 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> 
 
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.js"></script> 
 
    <link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" /> 
 
    <link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" /> 
 
    <link rel="stylesheet" href="css/vista.css" type="text/css" /> 
 
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" /> 
 
    <script type="text/javascript" src="llibreries/jquery-latest.js"></script> 
 
    <script type="text/javascript" src="llibreries/jquery.tablesorter.js"></script> 
 
    <script type="text/javascript" src="js/docs.js"></script> 
 
    <script type="text/javascript" src="addons/pager/jquery.tablesorter.pager.js"></script> 
 
</head> 
 
    <body> 
 
    </body> 
 
</html>

+0

上面的代碼片段會給出錯誤,而其他的會運行而不會出現任何錯誤。 –

+0

v3.3.0已過時,請使用https://www.jsdelivr.com/projects/jquery.tooltipster –

相關問題