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.