jQuery的tablesorter的阿贾克斯表只选一个方向 [英] jquery tablesorter ajax table only sorting one direction

查看:98
本文介绍了jQuery的tablesorter的阿贾克斯表只选一个方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我通过jQuery的load命令装载的表。在负载功能的回调我启动tablesorter插件。出于某种原因,那么表只按降序排序没有上升。即使怪异,如果我按住shift键,将切换正确ASC和DESC之间?任何想法是怎么回事?

I have a table that I load via a jQuery load command. in the callback of the load function I initiate the tablesorter plugin. For some reason then the table only sorts descending not ascending. Even weirder, if I hold shift it will toggle correctly between asc and desc? Any idea what's going on here?

table.php

table.php

<table id="xyz">
<thead>
    <tr>
        <th>hi</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>a</td>
    </tr>
    <tr>
        <td>b</td>
    </tr>
    <tr>
        <td>c</td>
    </tr>
</tbody>
</table>

jQuery的

jquery

$("#myDiv").load("table.php", function() {
    $("#xyz").tablesorter();
});

如果我不通过AJAX装载表则tablesorter的功能如预期。

if I don't load the table via ajax then the tablesorter functions as expected.

推荐答案

好了,所以我是双重结合像杰森想。

Okay so I was double-binding like Jason thought.

我其实是调用一个类jQuery的负载功能,我有两个div的与我的页面类。因此,它实际上是调用回调函数两次?

I was actually calling jQuery's load function on a class and I had two div's with that class on my page. So it actually was calling the callback function twice?

我认为这是一种怪异的行为的内容被加载到这两个div的是一样的,但它看起来像jQuery不会单独Ajax调用每一个的div的。感谢您的意见!

I think it's kind of weird behaviour as the content being loaded into both divs was the same but it looks like jQuery does a separate ajax call for each of the divs. Thanks for your comments!

这篇关于jQuery的tablesorter的阿贾克斯表只选一个方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆