2

Terrible title -- sorry.

I'm working with Embedly and have found it somewhat difficult to understand.

My objective is to extract a title and url from an API then list about 25 titles and have a button that when pressed shows the embeded url from embed.ly.

My current struggle is that when I press the button to show the embeded url instead of it only showing for the 1 link that I pressed it decides to show all 25 links at once. Frustrating.

Here is my code:

$('#content').append('<div id="highlight"><h1 id="headline">
<a href="'+URL+'" base target="_blank">'+title+'</a></h1></br>
<img class="dropDown" src="images/drop-down.png" alt=""/>
<a class="embedly-card" href="'+URL+'"></a></div></br>');

$('.embedly-card').hide().removeClass('hide');

So this is working well, embedly-card is hiding and all is perfect. The part that I am struggling with is:

$(".dropDown").click(function() {
$(this).siblings('.embedly-card').toggle().toggleClass('toggle');

//This is the embedly code that creates the embeded features...
!function(a){var b="embedly-platform",c="script";if(!a.getElementById(b)){var d=a.createElement(c);d.id=b,d.src=("https:"===document.location.protocol?"https":"http")+"://cdn.embedly.com/widgets/platform.js";var e=document.getElementsByTagName(c)[0];e.parentNode.insertBefore(d,e)}}(document);
//End of embedly code...

$(this).toggleClass("on");

So as I said earlier, instead of toggling just the 1 url that I intend it to embed it embeds ALL 25 urls when I click dropDown and I'm at a loss. How would I fix this? Thanks.

1 Answers1

0

This should give you an idea of the problem.

$('.dropDown').each(function(){
  // $(this) is each .dropDown
  // so it's like $(this).click(function(){});
}

You want to do it to each one. I don't see enough code to conclude anything else, or if the rest of your code is correct.

StackSlave
  • 10,613
  • 2
  • 18
  • 35
  • I tried substituting `$('.dropDown').each(function(){` with my `.click` function and it didn't seem to work. –  Jul 16 '14 at 00:18
  • Did you see where I commented out `$(this).click(function(){})`? – StackSlave Jul 16 '14 at 00:34
  • I don't have `$(this).click(function(){})` in my code. What I did was I simply replaced `$(".dropDown").click(function() {` with `$('.dropDown').each(function(){`. –  Jul 16 '14 at 00:55