jQuery ready event not fired on partial page load jQuery ready event not fired on partial page load ajax ajax

jQuery ready event not fired on partial page load


How are you firing the AJAX request to the server? If you're using ASP.NET AJAX, then Brian Hasden's answer is what you are looking for. If you are using jQuery to send the request, then you can either set a call back using the load function.

$(".ajaxLink").load(url, null, function() {    // code here});

load() Documentation

or set a global ajaxComplete event that is fired every time an ajax call is complete.

$(document).ajaxComplete(function() {    // code here});

ajaxComplete() Documentation


The load method offers a callback which is executed after the content has been loaded.

$("#myDiv").load(url, null, function() {    //do your stuff here });

Full documentation and examples at jQuery.com: http://docs.jquery.com/Ajax/load


OK.. so i have a simple answer to this problem now, which should mean minimal code changes. Rather than the sub views (these are real aspx views which have no html, head or body tags) having a js include (essentially the client side behaviour model) which responds to $(document).ready, we can use the suggestion from mkedobbs to provide something similar. Simply:

$("#MyDiv").load("page.htm", null, function(){ $(document).trigger("PartialLoaded"); });

Then in the sub view js include

$(document).bind("PartialLoaded", function(){ .........});