2

我在使用tablesorter 插件时遇到问题,似乎他无法执行对表格进行排序的功能,有人帮助我,我两天试图解决这个问题。

下面的错误

table.config.parsers[c] is undefined

Javascript:

<?php
    wp_register_script( 'jquery.tablesorter.js', get_bloginfo('template_url').'/js/jquery.tablesorter.js' );
    wp_enqueue_script( 'jquery.tablesorter.js' );
?>

表代码:

<table class="widefat tablesorter">
    <thead>
        <th width "70%">
        <u>Login do usuário:</u>  guilherme | <u>Nome do usuário:</u>    <span style="font-size:10;"> (<a href="admin.php?page=manage-files-main&deletefolder=/home/httpd/vhosts/simmmers.com.br/httpdocs/wp-content/uploads/file_uploads/62"> Deletar pasta</a>) </span> 
        </th>
        <th></th>
        <th>Date</th>
        <th width="20%">Category</th>
        <th width ="10%"></th>
    </thead>
    <tbody>
        <tr>
            <td>
            <input type="checkbox" name="change_cat1" value="addit" /> 
            <input type="hidden" name="file1" value="Indice de Confiança do Empresário Março-SC 2013.pdf.pdf" >
            <input type="hidden" name="changecat_user1" value="62"> 
            <img src="http://www.simmmers.com.br/wp-content/plugins/user-files/img/pdf.jpg" width="20" >   Indice de Confiança do Empresário Março-SC 2013.pdf
        </td>
        <td>
            <textarea name="notes1" rows=3 cols=30></textarea>
        </td>
        <td>25/03/2013</td>
        <td>Indicadores</td>
        <td align="right">
            <form method="post" action="/wp-admin/admin.php?page=manage-files-main">
            <a href="http://www.simmmers.com.br/wp-content/uploads/file_uploads/62/Indice de Confiança do Empresário Março-SC 2013.pdf.pdf" title="Download Indice de Confiança do Empresário Março-SC 2013.pdf.pdf">
            <img src="http://www.simmmers.com.br/wp-content/plugins/user-files/img/download.png"   alt="" width="20" height="20" /></a> |<input type="image" name="deletefile" value="62/Indice de Confiança do Empresário Março-SC 2013.pdf.pdf" title="Delete Indice de Confiança do Empresário Março-SC 2013.pdf.pdf" src="http://www.simmmers.com.br/wp-content/plugins/user-files/img/delete.png " alt="" width="20" height="20" /></form>    
        </td>
        </tr>
    </tbody>
</table>
4

2 回答 2

3

我知道答案有点晚了,但我发现,如果表为空(可能是由于 PHP 查询从 db 中产生了零行),则会触发此错误。

您可以使用一个简单的方法:如果表格为空,data-sort="table"则从表格标签中删除该属性。这样,如果你的 JS 代码是这样的:

    $("[data-sort=table]").tablesorter({
      sortList: [[0,0]]
    });

您可以确定它会避免所有空表,只留下准备好进行排序的填充表。

于 2017-11-28T00:07:39.427 回答
1

在我的情况下,我有一些行中有 colspans(有点像副标题行),并且 tablesorter 会在这些行上抛出异常。

于 2019-10-24T10:00:40.397 回答