2016-04-29 147 views
1

发布后更新面板Accordion无法正常工作。发布后更新面板Accordion不工作

下面是我的脚本:

$(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> 

回答

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> 
+0

如何为您的上述答案的slideToggle添加正负符号。 @Piyush Khatri – zahed

+0

我不明白,你能详细解释我吗? –

+0

我需要一些这样想我的幻灯片http://jsfiddle.net/aLcZa/3/。 @Piyush Khatri – zahed