它是确定使用google.setOnLoadCallback多次? [英] Is it ok to use google.setOnLoadCallback multiple times?
问题描述
我建立使用ASP.NET MVC的网站,我有使用jQuery做各种事情的局部视图。我想切换到谷歌的AJAX API和使用他们的加载器加载的jQuery。然而,我注意到,我将不再能够使用$(文件)。就绪()了,因为谷歌的装载机指定的回调google.setOnLoadCallback()。
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.
我想知道的,我可以指定多个回调,只是换出的$(document)。就绪()'s的google.setOnLoadCallback(someUniqueCallbackFunction)?
What I'm wondering is, can I specify multiple callbacks and just swap out the $(document).ready()'s with google.setOnLoadCallback(someUniqueCallbackFunction)?
那是要处理这种情况的理想方法还是有别的东西,是preferred?
Would that be the ideal way to handle this situation or is there something else that is preferred?
推荐答案
我可以在这里错过了点,但有你的用户控件的$(document)之间没有冲突。就绪和google.setOnLoadCallback,我知道的。
I may be missing the point here but there's no clash between your usercontrols $(document).ready and google.setOnLoadCallback that I know of.
假设你使用谷歌加载jQuery的,你的code在$(文件)。就绪将无法运行,直到谷歌加载jQuery的反正。
Assuming you're using google to load jquery, your code in the $(document).ready won't run until google has loaded jquery anyway.
只要被加载在你的母版的jQuery,不知道是什么的问题。
So long as jQuery is being loaded in your masterpage, not sure what the issue is.
这篇关于它是确定使用google.setOnLoadCallback多次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!