【问题标题】:table sorter not working on content reloaded with ajax表格排序器无法处理使用 ajax 重新加载的内容
【发布时间】:2012-04-26 06:08:51
【问题描述】:

我有一个非常奇怪的问题。 在我的网站上,我有两个非常相似的页面。 他们有一个使用 ajax 重新加载 div 的选项卡菜单。

在这个页面上

http://football-tennis-stats.com/index.php/stats/display_fotbal/

即使在更改国家/地区选项卡后也可以进行表格排序。

在这个上,它没有。

http://football-tennis-stats.com/index.php/stats/injury_list

我认为两个页面的代码是相同的。

在我的工作页面上

/get 表格结果....

$this->load->view('stats/football_tables',$data);

$this->load->view('stats/ajax_table_sorter.html');

在我没有工作的页面上

$this->load->view('stats/injuries',$data);
$this->load->view('stats/ajax_table_sorter.html');

ajax_table_sorter 只是一个简单的视图(我使用 Code Igniter)

<script type='text/javascript'>

$(document).ready(function ()
{

$('table').tablesorter();

});

据我所知,您必须再次重新加载调用表格排序器插件,正如您所见,我这样做了。 非常感谢任何帮助。

【问题讨论】:

  • 我注意到在加载伤害列表页面(不起作用的页面)时,我在萤火虫控制台中收到此错误,h[list[i][0]] is undefined ,但它仍然我第一次加载页面时工作。单击选项卡后它停止工作(使用 AJAX 重新加载)

标签: jquery tablesorter


【解决方案1】:

您已将此代码嵌入到您的 http://football-tennis-stats.com/js/table_sorter.js 文件中,当它尝试对 http://football-tennis-stats.com/index.php/stats/injury_list 上的第二个表(contry、伤害计数)进行排序时会引发错误,因为它们只有两列:

$("table").tablesorter({ 
    // sort on the first column and third column, order asc 
    sortList: [[0,0],[2,0]] 
});

您试图强制对第一列和第三列进行排序,因此会引发错误。

这是一个jsFiddle,使用您的表格排序器代码和类似表格。

【讨论】:

    猜你喜欢
    • 2015-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-30
    • 2017-03-15
    • 2011-04-30
    相关资源
    最近更新 更多