jQuery的$(文件)。就绪()不触发 [英] jQuery $(document).ready() not firing
问题描述
从谷歌使用jQuery 1.4.2托管code。
Using jQuery 1.4.2 from Google hosted Code.
是否有一个原因,下面的JavaScript不火的所有3的document.ready函数文档时准备好了吗?
Is there a reason why the following javascript does not fire all 3 document.ready functions when the document is ready?
第一个 $(文件)。就绪()
的功能,这使得头,第二个,这给'富'警告框被触发,但是后续的新的<脚本>
块不会被触发,
The first $(document).ready()
function, which renders headers, and the second, which gives a 'Foo' alert box triggered, but subsequent ones in new <script>
blocks aren't triggered,
<script type="text/javascript">
$(document).ready(function () {
Cufon.replace('h1'); // Works without a selector engine
Cufon.replace('h2'); // Works without a selector engine
Cufon.replace('h3'); // Works without a selector engine
Cufon.now();
});
$(document).ready(function () { alert("Number Foo"); });
</script>
// html tags
<script type="text/javascript">
$(document).ready(function () { alert("Number One"); });
$(document).ready(function () { alert("Number Two"); });
</script>
这些都是在单独的Web部件,在Sharepoint2010在同一页上托管
These are in seperate web parts, hosted on the same page in Sharepoint2010
推荐答案
我能想到的三个法医东西试试,马上
I can think of three forensic things to try, right off:
- 与非谷歌托管的尝试
库。 - 注释掉的Cufón
电话 - 我相信的Cufón做一些
疯狂的东西下载其他
资源,是吗?这可能是
干扰。 - 在子
$(窗口).load()
为一个或多个
你的$(文件)。就绪的()
回调DEFS。他们有不同的
发射标准 -$(窗口).load()
等待
一切都加载了,据称 -
但取代可以是
发人深省。
- try it with non-google-hosted libraries.
- comment out the Cufon calls -- I believe Cufon does some crazy stuff to download additional resources, yes? That may be interfering.
- sub in
$(window).load()
for one or more of your$(document).ready()
callback defs. They have different firing criteria --$(window).load()
waits for everything to load up, allegedly -- but the substitution may be revealing.
当然,的console.log()
和警报()
将是您-LEU-OF-在这种情况下调试器断点最好的朋友。
Of course, console.log()
and alert()
will be your in-leu-of-debugger-breakpoint best friends in this case.
这篇关于jQuery的$(文件)。就绪()不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!