I have a simple use case in which I need to dynamically add rows to a table in my HTML template. I am using the following javascript code to add this on a button click:
function add_row(){
row_html = '<tr><td><img src="path/to/my/file.png"></td></tr>'
$('#table-id').append(row_html);
}
The only problem is that the image is not being found. I have also tried using Django template language, doesn't work. One solution is defining the src in the script tag in my HTML template like in this question. However I am not sure this is the optimal approach.
What is the correct approach to solve this problem?