简体   繁体   中英

jQuery event to catch loaded content

I have aspx page with form which fire result to div on the same page. I need to process hrefs inside result output. Which action should be used in this case? $(document).ready and $(document).ajaxComplete didn't work. Concerning ajaxComplete as I understand it is because not a jQuery routine is used by page controls.

<script type="text/javascript" language="javascript">
$(document).ajaxComplete(function() {
    $('a[href*="mouz"]').removeAttr('href');
    });
</script>
<script type="text/javascript" language="javascript">
$(window).load(function() {
// executes when complete page is fully loaded, including all frames, objects and images
alert("window is loaded");
});
</script>

Here is the answer, adapted from MSDN - http://msdn.microsoft.com/en-us/library/bb397523(v=vs.100).aspx

In your client script add the following

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

to handle the event,

function pageLoaded(sender, args) {
  //get all of the panels which have been updated
  var updatedPanels = args.get_panelsUpdated(); 

  //perform the removal of the href attr on the DOM element collection
  $(updatedPanels).find('a[href*="mouz"]').removeAttr('href');

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM