我在使用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>

最佳答案

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

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

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


您可以确定它将避免所有空表,只剩下可以填充的已填充表。

10-01 09:13
查看更多