jsFiddle 完整代码: http://jsfiddle.net/bvmdW/
我使用了 jQuery嵌入以缩略图和视频替换 YouTube 链接。我在 CSS 中使用 display:none
隐藏视频部分。 Embedly 脚本会在此过程中动态创建以下 DOM:
<li id="1">
<img rel="vidPreview-1" class="embedly" src=".....">
<div id="vidPreview-1" class="vidPreview"> iframe videos here </div>
</li>
<li id="1">
<img rel="vidPreview-2" class="embedly" src=".....">
<div id="vidPreview-2" class="vidPreview"> iframe videos here </div>
</li>
和 jQueryTools
Overlay 插件来弹出隐藏的视频点击后我使用了:
$("img[rel]").live('click', function () {
$(this).overlay().load();
});
但 Overlay 插件似乎无法识别 live()
。在 Firebug 中,它表示:未捕获异常:找不到 Overlay:vidPreview-X
。 >
有人可以指导我如何使用 jQueryTools Overlay 制作 live()
吗?
jsFiddle Full Code: http://jsfiddle.net/bvmdW/
I used jQuery Embedly to replace YouTube links with thumbnail and videos. I hide the videos part using display:none
in CSS. The Embedly script will dynamically create the following DOM during the process:
<li id="1">
<img rel="vidPreview-1" class="embedly" src=".....">
<div id="vidPreview-1" class="vidPreview"> iframe videos here </div>
</li>
<li id="1">
<img rel="vidPreview-2" class="embedly" src=".....">
<div id="vidPreview-2" class="vidPreview"> iframe videos here </div>
</li>
Both <img rel="vidPreview-X"
and <div id="vidPreview-X
are dynamically generated by Embedly.
Now, I'll also use jQueryTools Overlay plugin to popup the hidden videos upon clicking the thumbnail. I used:
$("img[rel]").live('click', function () {
$(this).overlay().load();
});
but it seems the Overlay plugin doesn't recognize live()
. In Firebug it says that: uncaught exception: Could not find Overlay: vidPreview-X
Can someone please guide me how to make a live()
with jQueryTools Overlay?
发布评论
评论(2)
在 img 标签中,rel 属性中漏掉了 #。请将 # 添加到 rel attr 值中。再次检查。
In img tag you missed # in rel attribute.Please add # to the rel attr value.Check again.
我不确定,但尝试使用委托函数 http://api.jquery.com/delegate/
我曾多次遇到
live
的奇怪行为。I'm not sure, but try to use delegate function http://api.jquery.com/delegate/
I've faced with strange behavior of
live
for a few times.