1

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?

1
  • 2
    From this page example i found that You missed # in rel="vidPreview-1".Please check it or forget to post it here? Commented Jan 25, 2012 at 11:34

2 Answers 2

2

In img tag you missed # in rel attribute.Please add # to the rel attr value.Check again.

 <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>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help, it works now in modern browsers. However, it won't work in IE8 and IE7, it still shows and error: Error: Exception thrown and not caught
0

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.

1 Comment

"As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live()." api.jquery.com/live

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.