I use a basic.html in my flask application which loads all needed ressources like footer navbar etc., all my other html sites extend this basic.html
In my main.js I created a simple function:
function fun() {
alert("we have fun");
}
I load my files like this in the basic.html:
<script type=text/javascript src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script type=text/javascript src="{{ url_for('static', filename='js/bootstrap.js') }}"></script>
<script type=text/javascript src="{{ url_for('static', filename='js/main.js') }}"></script>
Now I want to use this function in my page.html which extends the basic.html:
{% extends "basic.html" %}
{% block content %}
<div class = "container" onload="fun()">
<p> Test </p>
</div>
{% endblock %}
Sadly nothing happens, but if I use the onload="fun()" in the basic.html itself it works.
So how do I resolve this?
This is a very simplified version of one of my previous question, due to the fact that I am sitting on this since 4 hours I think I know what causes the issue but I cant solve it and all solutions I found do not work.
Here is my previous question: question
I think that onload="fun()" is called before jQuery is even load or my main.js but I am still not 100% sure if this causes the error and I cant find a solution