Fix: Set title for multiple youtube video player with the same ID (don't rely on id to set title)

When an identical youtube video is embedded multiple times on the same page. 
it will only be successful setting title to 1st element in the dom matching a unique id which is based on the actual youtube video id.
This commit is contained in:
lidlanca 2014-10-14 19:50:42 -04:00
parent cd8b896272
commit 17febe4914
1 changed files with 2 additions and 2 deletions

View File

@ -33,9 +33,9 @@
})
.html('<p id="lazyYT-title-' + id + '" class="lazyYT-title"></p><div class="lazyYT-button"></div>')
.addClass('lazyYT-image-loaded');
$el_title = $el.find("p.lazyYT-title"); //get reference to the current container title element
$.getJSON('https://gdata.youtube.com/feeds/api/videos/' + id + '?v=2&alt=json', function (data) {
$('#lazyYT-title-' + id).text(data.entry.title.$t);
$el_title.text(data.entry.title.$t);
});
$el.on('click', function (e) {