SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Reset YouTube URL inside jQuery lightbox - DRIVING ME NUTS!

    Hi guys,

    Can I get a little help here? Trying to configure a page to display different videos inside a lightbox, on click. I was experiencing a bug where the video would continue to play after the lightbox was closed. This was fixed, but now, the lightbox keeps playing the same video, even if I click other videos on the page.

    Here's the JS Fiddle: http://jsfiddle.net/AM9FX/4/

    Thanks in advance to anyone who can help me out... This is driving me absolutely insane. I know it's probably an easy fix.

    Code JavaScript:
    var video = $('.window iframe[src*="youtube"]');
     
        if (video.length > 0) {
          var src = video.attr('src');
          video.attr('src','');
          video.attr('src', src);
        }

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,313
    Mentioned
    178 Post(s)
    Tagged
    8 Thread(s)
    There are lots of ways to do this, but maybe the most simple would be to store the name of the file to play as a data-attribute on the links?

    Code:
    <a href="#" data-name="pTp7PN2AKeU" name="lightbox">View TV Spot</a>
    <a href="#" data-name="XPwnz_8IqDU" name="lightbox">View TV Spot</a>
    Then just set the iframe's src when you open the lightbox.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •