[英]jquery scrollpane ms ajax updatepanel doesn’t work after post back
[英]jquery doesn't work after ajax auto refresh the updatepanel
<script>
!window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
</script>
//this the jquery I'm using
<script type="text/javascript" src="jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript">
//the function calls the query
$(document).ready(function x() {
/*
* Examples - images
*/
//set the position of title on image
$("a#example7").imagebox({
'titlePosition': 'inside'
});
});
</script>
在 updatepanels 的異步頁面回發期間,$(document).ready 函數不會被觸發,因此必須以其他方式執行 $(document).ready 的代碼。
您可以執行以下兩種方式中的任何一種:
第一種方式:
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
function InitializeRequest(sender, args) {
//do any action that you want to be executed before postbacks
}
function EndRequest(sender, args) {
$("a#example7").imagebox({
'titlePosition': 'inside'
});
}
</script>
第二種方式,即使用 RegisterStartupScript:
<script type="text/javascript">
function CreateImageBox() {
$("a#example7").imagebox({
'titlePosition': 'inside'
});
}
</script>
在 C# 代碼中使用:
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanelTab.GetType(), "createimagebox", "CreateImageBox();", true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.