回发后更新面板Accordion Not work。
以下是我的剧本:
$(document).ready(function () {
$("DIV.Accordion > DIV.collapsePanelHeader").click(function () {
$(this).next("DIV.Content").slideToggle("slow");
$("DIV.Accordion > DIV.Content").not($(this).next("DIV.Content")).slideUp("slow");
});
});
我在下面的脚本中尝试了这个,并在脚本块中添加了上面的脚本代码,但是根据不起作用:
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
if (args.get_error() == undefined) {
$(function () {
//Your script
});
}
}
</script>
答案 0 :(得分:1)
尝试以下,
<script type="text/javascript">
// below will execute after ajax postback
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
OnLoadPage();
}
function OnLoadPage() {
$(document).ready(function () {
$("DIV.Accordion > DIV.collapsePanelHeader").click(function () {
$(this).next("DIV.Content").slideToggle("slow");
$("DIV.Accordion > DIV.Content").not($(this).next("DIV.Content")).slideUp("slow");
});
});
}
// executes after page load first time
OnLoadPage();
</script>