4 Replies - 826 Views - Last Post: 15 May 2015 - 10:25 AM

#1 Charlie_Kay   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-May 15

jQuery not working the second time with play/pause buttons

Posted 14 May 2015 - 01:03 PM

I want to be able to play uploaded songs from a dynamic created folders(source) similar to reverb, soudcloud... This is running on rails App with below generated html source code.

Problem is only the latest uploaded song within the first nested (<ul>..</ul>) plays.The rest are not playing. I think jQuery is not working on the subsequent songs since the buttons are inactive. Any help on this will be great please?

Edit Fiddle: http://jsfiddle.net/91fgth2f/8/

Is This A Good Question/Topic? 0
  • +

Replies To: jQuery not working the second time with play/pause buttons

#2 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2487
  • View blog
  • Posts: 7,538
  • Joined: 15-January 14

Re: jQuery not working the second time with play/pause buttons

Posted 14 May 2015 - 02:02 PM

The problem is probably that you're using the same IDs for different elements. IDs like "play", "pause", and "playlist" are used multiple times.
Was This Post Helpful? 1
  • +
  • -

#3 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: jQuery not working the second time with play/pause buttons

Posted 14 May 2015 - 04:05 PM

Moved to jQuery forum.
Was This Post Helpful? 0
  • +
  • -

#4 Charlie_Kay   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-May 15

Re: jQuery not working the second time with play/pause buttons

Posted 14 May 2015 - 09:59 PM

View PostArtificialSoldier, on 14 May 2015 - 02:02 PM, said:

The problem is probably that you're using the same IDs for different elements. IDs like "play", "pause", and "playlist" are used multiple times.


Yes, I agree with you, it's a good point. I'm trying to get my head around how I can use different IDs
Was This Post Helpful? 0
  • +
  • -

#5 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2487
  • View blog
  • Posts: 7,538
  • Joined: 15-January 14

Re: jQuery not working the second time with play/pause buttons

Posted 15 May 2015 - 10:25 AM

You may be able to use classes instead of IDs for some things, otherwise you could have numbered IDs (playlist1, playlist2, etc) and pass the number into the init function to target the IDs with that number.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1