灯箱不适用于 Rails,即使页面加载文档已准备好在代码中
Lightbox not working with Rails, even when document on page load ready is in the codes
我正在使用带有Rails的Lightbox。
我已经用灯箱加 jquery.js 文件做了大家在堆栈溢出上建议的事情,以停止涡轮链接。 即
var ready;
ready = function() {
<the downloaded codes>
};
$(document).ready(ready);
$(document).on('page:load', ready);
但是我的图片库仍然无法正常工作,不要认为我的代码是错误的,因为我的所有其他 JS 文件都可以使用上述代码?
我的网页代码:
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-3.jpg" data-lightbox="example-set" data-title="Click the right half of the image to move forward."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-3.jpg" alt=""/></a>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-4.jpg" data-lightbox="example-set" data-title="Or press the right arrow on your keyboard."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-4.jpg" alt="" /></a>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-5.jpg" data-lightbox="example-set" data-title="The next image in the set is preloaded as you're viewing."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-5.jpg" alt="" /></a>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-6.jpg" data-lightbox="example-set" data-title="Click anywhere outside the image or the X to the right to close."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-6.jpg" alt="" /></a>
CSS代码是从站点下载的默认代码。
以前有人成功使用过带导轨的灯箱吗?或者可以帮助我破解这个案子?
提前谢谢。
我遇到了同样的问题。这不是轨道问题。
你应该把
<script src="lightbox/lightbox-plus-jquery.js"></script>
(或等效项)到 HTML 中正文标签的末尾,而不是头部。问题是,如果脚本在头部,它将在图像准备好被库解析之前运行。
相关文章:
- BrowserId登录请求在文档加载时被调用
- JS触发器值检查在文档加载后添加到页面的元素在加载时更改AND
- 在文档加载Tampermonkey时单击事件激发
- 为什么不是'我的函数未按预期在文档加载时运行
- Focusout 仅在文档加载时触发,并且不会再次触发
- 在文档加载时禁用 JCrop
- 为什么当文档加载 jQuery 时我不能直接调用函数
- 在文档加载和函数调用时,行的选择方式不同
- jQuery没有't使用文档加载后创建的元素
- 将文档加载到 iframe jquery 中
- 在文档加载时使用 JQuery 在下拉字段中设置默认值
- 将 CSS 添加到文档加载后创建的元素
- jQuery 追加文档加载,追加两次,似乎不会等到文档加载完毕
- 文档加载对我不起作用
- 更少:文档加载后加载的文件上的“修改变量”
- 如何在文档加载后加载此 javascript 函数
- j查询文档加载时,每 3 秒检查一次并重新加载
- 如何检测文档加载已通过javascript启动
- JQuery函数未在文档加载时执行
- Jquery反弹动画函数来处理文档加载