From 17febe4914d69c6dbe19d459516c8ccf5650c0a5 Mon Sep 17 00:00:00 2001 From: lidlanca Date: Tue, 14 Oct 2014 19:50:42 -0400 Subject: [PATCH 1/2] 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. --- plugins/lazyYT/assets/javascripts/lazyYT.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lazyYT/assets/javascripts/lazyYT.js b/plugins/lazyYT/assets/javascripts/lazyYT.js index 747ea69229c..566135495c7 100644 --- a/plugins/lazyYT/assets/javascripts/lazyYT.js +++ b/plugins/lazyYT/assets/javascripts/lazyYT.js @@ -33,9 +33,9 @@ }) .html('

') .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) { From 432aa762215babd38406cf09286e19fe713802d7 Mon Sep 17 00:00:00 2001 From: lidlanca Date: Tue, 14 Oct 2014 20:38:59 -0400 Subject: [PATCH 2/2] var are you? --- plugins/lazyYT/assets/javascripts/lazyYT.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/lazyYT/assets/javascripts/lazyYT.js b/plugins/lazyYT/assets/javascripts/lazyYT.js index 566135495c7..3df9eb1f52a 100644 --- a/plugins/lazyYT/assets/javascripts/lazyYT.js +++ b/plugins/lazyYT/assets/javascripts/lazyYT.js @@ -33,7 +33,9 @@ }) .html('

') .addClass('lazyYT-image-loaded'); - $el_title = $el.find("p.lazyYT-title"); //get reference to the current container title element + + var $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) { $el_title.text(data.entry.title.$t); });