I have defined my javascript file inside static folder of my django project with path js/info.js
and content as follows:-
function info()
{
$('#outer_info').append('<div id="get_info"></div>');
console.log('info_btn clicked')
document.getElementById('get_info').innerHTML = `<div class='modal fade' id='exampleModal1' tabindex='-1' aria-labelledby='exampleModal1Label' aria-hidden='true'>
<div class='modal-dialog modal-dialog-centered modal-md'>
<div class='modal-content' style='background-color:#47423e;'>
<div class='modal-header'>
<h3 class='modal-title text-white' id='exampleModal1Label'>xbguvolrtktest</h3>
<button type='button' class='btn-close' data-bs-dismiss='modal' aria-label='Close'></button>
</div>
<div class='modal-body'>
<center><h3 class="text-white">Bucket Details</h3>
<table class="table table-dark table-sm table-hover border-white">
<tbody>
<tr>
<td class="text-white">Items in Bucket:</td>
<td class="text-white">{{ bucket_item_count }}</td>
</tr>
<tr>
<td class="text-white">Bucket Size:</td>
<td class="text-white">{{ bucket_size }}</td>
</tr>
<tr>
<td class="text-white">Last Updated On:</td>
<td id="last_updated" class="text-white">{{ last_updated_time }}</td>
</tr>
<tr>
<td class="text-white">Directories:</td>
<td class="text-white">{{ directory_count }}</td>
</tr>
<tr>
<td class="text-white">Files:</td>
<td class="text-white">{{ file_count }}</td>
</tr>
</tbody>
</table>
<br></center>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-secondary' data-bs-dismiss='modal' style='background:#e2513c'>Close</button>
</div>
</div>
</div>
</div>
<input type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal1" data-bs-whatever="@mdo" id="infoButton" hidden>`
document.getElementById("infoButton").click();
}
Here is how it is being called in index.html
file:-
<script src="{% static '/js/info.js' %}" type="text/javascript"></script>
This is basically a Bootstrap Modal. The problem is that the value of the django variables is not getting rendered on html although it works fine when I include the entire script inside index.html
directly.
Here is how it looks:-
What might be going wrong here?