Click here to Skip to main content
12,946,658 members (50,081 online)
Click here to Skip to main content
Add your own
alternative version

Stats

12.3K views
2 bookmarked
Posted 12 Jul 2011

JavaScript function to be called after UpdatePanel refreshes

, 16 Jul 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
A method to call a function in JavaScript after each response.

I was searching for a method to call a function in JavaScript after each response. I found a method to do this:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded


I also made a function to manage the loading of DOM objects.
$.PlanetAspNet.setReady('.hint',function(hint){
    hint.each(function(){
        var $span = $(this);
        $span.siblings('input')
             .focus(function(){ $span.show()})
             .blur(function(){ $span.hide()});

Here is the JavaScript function after UpdatePanel refreshes. In this case, the function will be called on document ready and after each DOM object is created after ASPNET Async.


$.PlanetAspNet = {
    options: [],
    PageLoadedHandler: function(sender,e){
        if (e._panelsUpdated.length==0){
            $.PlanetAspNet.Ready(document,e);
        }else{
            $.each(e._panelsUpdated,function(){
                $.PlanetAspNet.Ready(this,e);
            });
        };
    },
    setReady: function(selector,fn){
        $.PlanetAspNet.options.push({selector:selector,fn:fn});
        return $.PlanetAspNet.options;
    },
    Ready: function(item,e){
        $.each($.PlanetAspNet.options,function(){
            var o = $(item).find(this.selector);
            if (o.length>
0) this.fn(o,item,e);
        });
        return item;
    }
};

I hope this helps.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

joetavMB
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170518.1 | Last Updated 16 Jul 2011
Article Copyright 2011 by joetavMB
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid