I am trying to implement this code to my Django application. I manage to get the code on the page using code blocks in my index.html.
It seems like the styles from the css is displaying correctly. I also manage to play songs, but the pause button, different cover images and song titles does not change when they are clicked/changed.
For me it seems like the JavaScript is not able to change the style of html elements in the DOM.
I know that JS files is not processed by Django's template engine. So I am using this code, so I can reference this global variable from within the js-file.
<script>
var MEDIA_URL = "{{MEDIA_URL}}";
</script>
<script type="text/javascript" src="{{MEDIA_URL}}/js/myscript.js" ></script>
inside the JS file there is two places where the variable is referred,
$('.player .cover').css('background-image','url(MEDIA_URL + audio/' + cover+')');;
song = new Audio(MEDIA_URL+'audio/' + url);
This reference do actually take place, but for the rest of the JS-file.. none of the addClass, removeClass etc. do affect the DOM.
When trying this code outside the Django framework, everything works as expected.I am pretty sure that there is something I am ignoring, that is causing this problem.. but I cannot seem to figure out what it is!
Please help!