AJAX调用后jQuery的tablesorter插件不工作 [英] jQuery tablesorter plugin does not work after AJAX call

查看:178
本文介绍了AJAX调用后jQuery的tablesorter插件不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用jQuery的表选机插件在我的code。它工作得很好,只要我没有做一个Ajax请求动态加载表数据。我使用的组合框阿贾克斯过滤表中的内容。我读它说用 $(表)几个帖子触发(更新); 可以解决我的问题。我试图用我的code,但问题依然存在。

I have used jQuery table sorter plugin in my code. It works fine as long as I don't make an ajax request to load the table data dynamically. I am using combo boxes to filter the contents of the table by ajax. I read few posts which says using $("table").trigger("update"); can solve my problem. I tried it with my code but the problem is still there.

有没有解决这个问题的任何其他方式?请帮我找出一个解决方案。我真的陷入糟糕。任何帮助将是AP preciated。下面是我的code:

Is there any other way to solve this problem? Please help me figure out a solution. I am really stuck bad. Any help would be appreciated. Below is my code :

$(document).ready(function () {
    $("#myTable").tablesorter({
        widthFixed: true,
        widgets: ['zebra'],
        headers: {
            0: {
                sorter: false
            }
        }
    }).tablesorterPager({
        container: $("#pager")
    });

    $("#tag").change(function (event) {
        $('#myTable').trigger("update");
        $("#myTable").tablesorter();
    });
});

下面的标签是一个组合框指定标签的ID,并为myTable是表与分选寻呼机插件的ID。

Here tag is the id of a combo box named tag and myTable is the id of the table with sorter pager plugin.

推荐答案

我想换行的tablesorter功能,在它自己的功能。

I would wrap the tablesorter function in it's own function.

然后,每当您需要重新运行它 - 只需再次调用它

Then whenever you need to re run it - just call it again.

$(document).ready(function () {
    function resortTable(){ 
          $("#myTable").tablesorter({
            widthFixed: true,
            widgets: ['zebra'],
            headers: {
                0: {
                    sorter: false
                }
            }
        }).tablesorterPager({
            container: $("#pager")
        });
    }

        $("#tag").change(function() {
            resortTable();
        });
});

这篇关于AJAX调用后jQuery的tablesorter插件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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