I am populating page with html loaded from controler by calling
$("#test").load("{% url 'simple_dataframe' %}");
'simple_dataframe' is pandas.to_html() method which is returning proper html for datatables jquery.
Next script is:
<script>
$(document).ready(function () {
$('#df_table').DataTable();
});
</script>
Which doesnt load properly. I have copied returned html to page and run it with only DataTable jquery and it runs fine. So its not related to malformed html. I think its something to do with the order in which scripts are called.
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="{% static '/css/bootstrap.min.css' %}" type="text/css"/>
<link rel="stylesheet" href="{% static '/css/jquery.dataTables.css' %}" type="text/css"/>
<script src="{% static "js/jquery-3.3.1.min.js" %}"></script>
<script src="{% static 'js/jquery.dataTables.js' %}"></script>
</head>
<body>
<div id="test"></div>
<script>
$(document).ready(function () {
$("#test").load("{% url 'simple_dataframe' %}");
});</script>
<script>
$(document).ready(function () {
$('#df_table').DataTable();
});
</script>
</body>
</html>