表格排序:table.config.parsers [c]未定义

wqui 发布于 2019-03-15 javascript 最后更新 2019-03-15 14:53 5 浏览

我在使用tablesorter plugin时遇到了问题,他似乎无法执行排序表的功能,有人帮助我,我花了两天的时间来解决这个问题。 在错误之下

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>
已邀请:

frerum

赞同来自:

我知道答案有点晚了,但我发现,如果表是空的(可能是由于PHP查询产生了来自db的零行),则会触发此错误。 您可以使用一种简单的方法:如果表为空,则从表标记中删除data-sort="table"属性。这样,如果您的JS代码是这样的:

    $("[data-sort=table]").tablesorter({
      sortList: [[0,0]]
    });
你可以肯定它会避免所有空表,只留下已填充的表,以便进行排序。