jQuery sorttable在updatepanel(JavaScript)中回发后不起作用

Fre*_*ddy 2 javascript jquery updatepanel tablesorter jquery-ui-sortable

我有一个jQuery的可排序函数的问题.当我的页面使用更新面板进行回发时,动态表的排序不再起作用.按下图像按钮时会触发回发.按下图像按钮时,会有一个新行,其中包含子表.

我尝试了这3个JavaScript代码,但它们似乎只是第一次工作.打开子表后,它们不起作用.

你们可能知道一个JavaScript解决方案来解决这个问题吗?

我的第一次尝试:

$(function(){
        $('table[id*="tbl_main"]').tablesorter();
    });
Run Code Online (Sandbox Code Playgroud)

我的第二次尝试:

$(document).ready(function(){
        $('table[id*="tbl_main"]').tablesorter();
    });
Run Code Online (Sandbox Code Playgroud)

我的第三次尝试:

function pageLoad() {
        $(function () {
            $("#pager").unbind();
            $('table[id*="tbl_main"]')
            .tablesorter()
            .tablesorterPager({ container: $("#pager") });
        }
    )}
Run Code Online (Sandbox Code Playgroud)

el *_*vis 9

每次更新后,所有脚本都会被删除,您必须再次绑定它们,如:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

     <ContentTemplate>
          <script type="text/javascript">
               Sys.Application.add_load(BindFunctions);
          </script>
...
Run Code Online (Sandbox Code Playgroud)

然后在你的javascript文件中:

function BindFunctions() {
$('table[id*="tbl_main"]').tablesorter();
};
Run Code Online (Sandbox Code Playgroud)