1

I have this table where the is initially blank. Then when the document is ready I call a function that runs an AJAX query for the table content. The initial content is sorted awesomely! But when I call my function again with different parameters to get new content, things start to go wrong. The table fills with the new content just fine, but clicking on a header column to sort reverts the table content back to what it was when the page first loaded and the sorting also stops working.

This is the code snippet that I am using. will using $('.tablesorter').trigger("update") help? At what point should i make a call to this?

jQuery(".tablesorter > tbody").load(path, function(){
    jQuery(".tablesorter").tablesorter({
                    onRenderHeader: function (){
                    this.wrapInner("<span></span>");
                }
                , widthFixed: true
                , widgets: ['zebra','hovering','selected']
                , debug: true
              });
}

Thanks, MM

4

4 回答 4

2

我相信您需要使用 livequery 让 tablesorter 了解新的 ajax 内容。

这个花了我一段时间来解决这个问题,但基本上这应该可以工作,在你包含 livequery js 之后:

$("#table").livequery(function(){
  $(this).tablesorter({
    ...
  })
});

诺亚

于 2009-02-17T15:23:56.957 回答
0

如果您无法触发小部件,请调用此方法$("Table").trigger("applyWidgets");

这将确保所有小部件,如斑马效果、悬停等。将被启用。

于 2013-05-07T12:24:55.563 回答
0

只需使用

$(".tablesorter").livequery(function(){
    $(this).tablesorter({
    .
    .
    .
    });
});
于 2015-02-19T12:27:05.913 回答
0
include  $("#table_name").tablesorter(); in ajax call.

您需要通过 ajax 调用挂钩 tablesorter 功能。

如果您以这种方式挂钩,新表格内容也将具有排序功能。

于 2015-02-19T12:22:21.410 回答