Having an issue retrieving a picture from my static files using a JavaScript function.
Here is the JavaScript code in question:
<script type="text/javascript">
var url_1 = '{% static "assets/img/stolovi/2.jpg" %}';
function addimage1() {
var img = document.createElement("img");
img.src = url_1;
img.height = 50;
img.width = 50;
img.draggable = true;
//optionally set a css class on the image
var class_name = "foo";
img.setAttribute("class", class_name);
document.getElementById("myDiagramDiv").appendChild(img);
//document.body.appendChild(img);
$(img).draggable({containment:'#myDiagramDiv'});
}
</script>
How can I successfully fetch the picture in my addimage1 function and assign it to img.src?
My script tag is embedded inside an HTML element, unsure if that's relevant information.