使用.trigger('click')自动加载fancybox [英] Auto load fancybox using .trigger('click')
问题描述
我只是想知道能否请您帮忙.我正在尝试 fancybox在页面呈现后自动加载.但是,我 在第18行(/js/fancybox/ jquery.fancybox-1.3.3.pack.js).目前,我正在使用jquery 版本1.4.2
I was just wondering if you could please help. I am trying to get the fancybox to load automatically once the page is rendered. However, I got this error message 't is undefined' at line 18 (/js/fancybox/ jquery.fancybox-1.3.3.pack.js). At the moment, I am using jquery version 1.4.2
<a href="#container" id="profile">Click me</a>
<div style="display:none">
<div id="container">Fancybox Content Here .... </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#profile').fancybox().trigger('click');
});
</script>
有趣的是,如果我选择下面的代码行并在Firebug中运行它 控制台,然后工作!不知道我在这里做错了什么.您的帮助 将不胜感激.
The funny thing is if I take the line below and run it in firebug console then it WORKS!. Not sure what did I do wrong here. Your helps would be grateful.
$('#profile').fancybox().trigger('click');
谢谢
推荐答案
我遇到了同样的问题.使用解压缩版本进行测试,我在第36行(fancybox 1.3.4)中得到了"loading is undefined".所以我叫"$ .fancybox.init();"在触发之前,它现在可以正常工作.
I got the same problem. Testing with the unpacked version, i got "loading is undefined" in line 36 (fancybox 1.3.4). So I called "$.fancybox.init();" before triggering and it works correctly now.
这篇关于使用.trigger('click')自动加载fancybox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!