jQuery sorttable在updatepanel(JavaScript)中回发后不起作用 [英] jQuery sorttable doens't work after postback in updatepanel (JavaScript)
问题描述
我遇到了jQuery的可排序函数问题。当我的页面使用更新面板进行回发时,动态表的排序不再起作用。按下图像按钮时会触发回发。当按下图像按钮时,会有一个新行,其中包含一个子表。
I have a issue with the sortable function of jQuery. When my page does a post-back with the update-panel the sorting of the dynamic table doesn't work anymore. The post-back is triggerd when a image-button is pushed. When the image-button is pushed there is a new row with a subtable in it.
我尝试了这3个JavaScript代码,但它们似乎只是第一次工作。打开子表后它们不起作用。
I tried these 3 JavaScript codes but they all only seem to work for the first time. They DON'T work after I open the subtable.
你们可能知道一个JavaScript解决方案来解决这个问题吗?
Do you guys maybe know a JavaScript solution to solve this?
我的第一次尝试:
$(function(){
$('table[id*="tbl_main"]').tablesorter();
});
我的第二次尝试:
$(document).ready(function(){
$('table[id*="tbl_main"]').tablesorter();
});
我的第三次尝试:
function pageLoad() {
$(function () {
$("#pager").unbind();
$('table[id*="tbl_main"]')
.tablesorter()
.tablesorterPager({ container: $("#pager") });
}
)}
推荐答案
每次更新后,所有脚本都被删除,你必须再次绑定它们,如:
After each update all scripts are removed, you have to bind them again like:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<script type="text/javascript">
Sys.Application.add_load(BindFunctions);
</script>
...
然后在你的javascript文件中:
And then in your javascript file:
function BindFunctions() {
$('table[id*="tbl_main"]').tablesorter();
};
这篇关于jQuery sorttable在updatepanel(JavaScript)中回发后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!