I'm building a site using ASP.NET MVC, and I have partial views that use jQuery to do various things. I was thinking of switching to Google's AJAX API and using their loader to load jQuery. However, I noticed that I would no longer be able to use $(document).ready()
anymore because Google's loader specifies a callback google.setOnLoadCallback()
.
This is a little bit of a problem for me because I have $(document).ready()
in various partial views because they do different things specific to themselves that I don't want the parent view to be aware of.
Can I specify multiple callbacks and just swap out the $(document).ready()
's with google.setOnLoadCallback(someUniqueCallbackFunction)
?
Would that be the ideal way to handle this situation or is there something else that is preferred?
I may be missing the point here but there's no clash between your usercontrols $(document).ready and google.setOnLoadCallback that I know of.
Assuming you're using google to load jquery, your code in the $(document).ready won't run until google has loaded jquery anyway.
So long as jQuery is being loaded in your masterpage, not sure what the issue is.