【问题标题】:Tablesorter : TypeError: c is undefined :::: c.page++;Tablesorter : TypeError: c is undefined :::: c.page++;
【发布时间】:2014-07-12 05:58:36
【问题描述】:

您好,我正在使用 tablesorter Link .. 如果我包含“ page_my(_($help_context = "Table")); " --- 这是我的标题部分,我的分页将无法正常工作

header 部分:基本上包括 HTML 标签和 session 值 ...我教过因为我的 session 和 php 代码可能导致不运行分页,因此我删除了所有 php 和 session 代码..但它仍然无法正常工作......也没有其他JS文件包含在这个

下面是我的代码

<?php  

$page_security = 'SA_TABLESORTER';
$path_to_root = "..";

include($path_to_root . "/includes/session.inc");

page_my(_($help_context = "Table"));


        echo'

    <link rel="stylesheet" href="table/style.css" type="text/css" media="print, projection, screen" />

        <script src="table/jquery-latest.js"></script>       
        <script src="table/jquery.tablesorter.js"></script>
        <script src="table/jquery.tablesorter.widgets.js"></script>
        <script type="text/javascript" src="table/jquery.tablesorter.pager.js"></script> 
        <script type="text/javascript">
        $(function() { 

        $("table").tablesorter({ 
        widthFixed: true, widgets: ["zebra", "filter"], 

        headers: { 5: { sorter: false, filter: false } }, 

        widgetOptions : { 

        filter_cssFilter : \'tablesorter-filter\', 

        filter_childRows : false, 


        filter_startsWith : false 

        } 

        })
        .tablesorterPager({container: $("#pager")})  ;
        });

        </script>';



?>


 <table id="myTable" class="tablesorter">
<thead>
<tr>
    <th>Last Name</th>
    <th>First Name</th>
    <th>Email</th>
    <th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
    <td>Smith</td>
    <td>John</td>
    <td>jsmith@gmail.com</td>
    <td>http://www.jsmith.com</td>
</tr>
<tr>
    <td>Doe</td>
    <td>Jason</td>
    <td>jdoe@hotmail.com</td>
    <td>http://www.jdoe.com</td>
</tr> 
        <tr>
            <td>Student01</td>
            <td>Languages</td>
            <td>male</td>
            <td>80</td> 
        </tr>   
            <tr>
            <td>Student02</td>
            <td>Mathematics</td>
            <td>male</td>
            <td>90</td>
        </tr>
    <tr>
    <td>Smith2</td>
    <td>John</td>
    <td>jsmith@gmail.com</td>
    <td>http://www.jsmith.com</td>
</tr>
<tr>
    <td>Doe1q</td>
    <td>Jason</td>
    <td>jdoe@hotmail.com</td>
    <td>http://www.jdoe.com</td>
</tr> 
            <tr>
            <td>Student03</td>
            <td>Languages3</td>
            <td>male3</td>
            <td>180</td> 
        </tr>   
            <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>
                <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>
                <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>
                <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>           <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>           <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>           <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>           <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>           <tr>
            <td>Student04</td>
            <td>Mathematics4</td>
            <td>male4</td>
            <td>190</td>
        </tr>


</tbody>
</table>


<?php

echo"<div id=\"pager\" class=\"pager\">
    <br \>
    <form>
        <img src=\"table/first.png\" class=\"first\"/>
        <img src=\"table/prev.png\" class=\"prev\"/>
        <input type=\"text\" class=\"pagedisplay\"/>
        <img src=\"table//next.png\" class=\"next\"/>
        <img src=\"table/last.png\" class=\"last\"/>
        <select class=\"pagesize\">
            <option selected=\"selected\"  value=\"10\">10</option>
            <option value=\"20\">20</option>
            <option value=\"30\">30</option>
            <option  value=\"40\">40</option>
        </select>
    </form>
</div>"; 
?>



<?php
br(1);
end_page();  // footer section
?>

如果我删除“page_my(_($help_context = "Table"));” - 这个函数然后我的分页工作正常但是如果我包含这个函数(我的标题部分)然后我得到 错误萤火虫

TypeError: c 未定义

c.page++;在“jquery.tablesorter.pager.js”的链接 46 处

这是:

function moveToNextPage(table) { 
            var c = table.config;
            c.page++;
            if(c.page >= (c.totalPages-1)) {
                c.page = (c.totalPages-1);
            }
            moveToPage(table);
}

【问题讨论】:

  • 错误意味着table.config变量中没有属性'page'..你为什么不使用更好的表格排序插件,比如datatables.net
  • 嘿Bhavesh,谢谢你的回复..老兄,但正如我所说..当我删除“page_my(_($help_context = "Table"));”然后也可以正常工作..这个功能有我所有的 HEADER SECTION 内容
  • bhavesh : +1 数据表链接.. 谢谢
  • 这里的任何人......仍在等待答案

标签: javascript jquery pagination tablesorter


【解决方案1】:

我想知道您使用的是什么版本的 tablesorter。您分享的链接指向原始 tablesorter v2.0.5b。

过滤器小部件是我的fork of tablesorter 的一部分,它需要从 GitHub 下载的插件和寻呼机的版本。您似乎使用了正确的文件,但请验证版本号。分叉目前为 2.17.4。

编辑:实际上,您共享的寻呼机代码看起来一点也不像当前代码:

moveToNextPage = function(table, p) {
    p.page++;
    if ( p.page >= ( Math.min( p.totalPages, p.filteredPages ) - 1 ) ) {
        p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 );
    }
    moveToPage(table, p);
}

【讨论】:

  • 嗨 Mottie,我使用过 tablesorter.com/__jquery.tablesorter.zip .. 你能分享我下载最新文件的确切链接吗?
  • mottie.github.io/tablesorter/docs点击页面顶部的版本号,或者滚动到页面底部看到“zip”和“tar.gz”下载按钮
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-01
  • 2021-11-24
  • 2021-07-04
  • 1970-01-01
  • 1970-01-01
  • 2021-06-21
  • 2020-08-15
相关资源
最近更新 更多