K
K
Kirill Noskov2015-03-04 20:24:50
JavaScript
Kirill Noskov, 2015-03-04 20:24:50

How to work with Jplayer (Jquery) plugin on different pages?

Hello! Just starting to get to the top of Jquery and using it to build a music web application. To play music I use the famous Jplayer plugin. There were no problems with the creation of one page, but when I decided to break the blocks with music into popular and latest, one small, but very unpleasant and extremely annoying problem appeared. When switching from the Popular block to the Last block, a script is loaded using Ajax, where the values ​​of the previous block with music are reset and a new one is loaded. The scripts are completely identical, just in each of them music is loaded from different files, but if in the first case everything works as it should, then in the second the music starts playing only after clicking the link again. Despite the fact that both the first and second cases use the same jplayer script, in which the settings should automatically play music after clicking on the link. I hope that I correctly explained the essence of the problem and I am grateful to everyone who read to the end. I can show you the code if needed. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-03-05
@k12th

You're trying to make a SPA the old fashioned way by loading bits of HTML with scripts. It's crooked, and will always work crookedly. Load data from the server into JSON, turn it into HTML using a template engine, and the number of problems will creep down sharply.
In this case, it looks like the Jplayer is being initialized twice. It is difficult to say more precisely, since you did not provide the minimum non-working code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question