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:

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

var video = $('.window iframe[src*="youtube"]');

    if (video.length > 0) {
      var src = video.attr('src');
      video.attr('src', src);

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?

<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.