How can I use jQuery $ (document) .ready and ASP.NET UpdatePanel together?

I am rocking this Javascipt bit in <head>my page section :

<script type="text/javascript">
    $(document).ready(function() {
        $('dl.expander dd').expander
        (
            {   slicePoint: 50,    widow: 2,   expandEffect: 'show', userCollapseText: '[^]' }
        );
    });
</script>

This works great on the first page load; however, when I click <asp:button>which is inside <asp:updatepanel>, the page partially refreshes, but $(document).readyis never called again.

This is important because this Javascript in the section $(document).readycollapses and adds the "readmore" parameter to the list of paraffin waxes (or dl with class = "expander") on the page, most of which should be dropped by default.

+3
source share
1 answer

endRequest AJAX. . . "" , ajax javascript, , .

http://www.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx

http://msdn.microsoft.com/en-us/library/bb383810.aspx

<script type="text/javascript">
    $(function() {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    });

    function EndRequestHandler(sender, args) {
        // code that you want to run when the request is complete
    }
<script>
+8

Source: https://habr.com/ru/post/1723131/


All Articles