2012-02-10 72 views
0

我有一個表的頁面,我使用jquery的tablesorter插件。偶爾我得到這個錯誤:Tablesorter jquery插件的錯誤

Message: Unable to get value of the property 'type': object is null or undefined Line: 8 Char: 2558 Code: 0

這是我在我的網頁代碼:

<script type="text/javascript"> 
       $(function() { 
        if ($("table#table_tb1").find("tbody").find("tr").size() > 1) { 
         $("table#table_tb1").tablesorter({ sortList: [[0, 1]] }); 
        } 
       }); 

IF子句是克服發生相同的插件中的錯誤時,該表是空的。

這是發生錯誤的tablesorter.js行:

var s=(table.config.parsers[c].type=="text")?((order==0)?makeSortFunction("text","asc",c):makeSortFunction("text","desc",c)):((order==0)?makeSortFunction("numeric","asc",c):makeSortFunction("numeric","desc",c)); 

提前感謝!

+1

您發佈的錯誤是來自壓縮版本,所以它很難確切地知道錯誤的位置,但您可能想看看[這個問題/答案](http://stackoverflow.com/questions/8581064/tablesorter-n0-undefined/8618359)查看是否可以解決您的問題。 – Mottie 2012-02-11 00:02:32

+0

謝謝,這聽起來類似於我面臨的問題。我會檢查出來的。 – Aniket 2012-02-15 07:01:36

回答

0

似乎很多人在搜索後都在這個問題上結束了,所以我會發布我自己的解決方案。

該表爲空。在表中有值並且問題消失。如果表格爲空,則不要初始化tablesorter插件。