We are using jQuery thickbox to dynamically display an iframe when someone clicks on a picture.
(当有人点击图片时,我们使用jQuery thickbox动态显示iframe。)
In this iframe, we are using galleria a javascript library to display multiple pictures.(在这个iframe中,我们使用galleria一个javascript库来显示多张图片。)
The problem seems to be that $(document).ready
in the iframe seems to be fired too soon and the iframe content isn't even loaded yet, so galleria code is not applied properly on the DOM elements.
(问题似乎是iframe中的$(document).ready
似乎很快被解雇,iframe内容甚至还没有被加载,所以galleria代码没有在DOM元素上正确应用。)
$(document).ready
seems to use the iframe parent ready state to decide if the iframe is ready.($(document).ready
似乎使用iframe父级就绪状态来判断iframe是否准备就绪。)
If we extract the function called by document ready in a separate function and call it after a timeout of 100 ms.
(如果我们在单独的函数中提取由文档就绪调用的函数,并在超过100毫秒后调用它。)
It works, but we can't take the chance in production with a slow computer.(它有效,但我们不能利用慢速计算机生产机会。)
$(document).ready(function() { setTimeout(ApplyGalleria, 100); });
My question: which jQuery event should we bind to to be able to execute our code when the dynamic iframe is ready and not just it's a parent?
(我的问题:我们应该绑定哪个jQuery事件,以便在动态iframe准备就绪时能够执行我们的代码,而不仅仅是它的父级?)
ask by EtienneT translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…