I want to implement the simple autocomplete function from google, as simple as in their example: Google Autocomplete Example
I created a random html page and tested the code with my API key, it worked fine.
Now I am struggling to implement this code into my flask application. I do not get any errors, but while I am entering a cityname there is no autocomplete and of course if I submit what I entered I get an error:
main.js:38 Uncaught TypeError: Cannot read property 'length' of undefined
I am loading my Jquery and my JS in my basic.html at the bottom in the footer (every of my other pages extends this basic html, because there is also the navbar and head):
{% block footer %}
<div class="container-fluid" id="footer">
<div class="col-sm-4">
<p> Footer Element </p>
<p> Footer Element </p>
<p> Footer Element </p>
<p> Footer Element </p>
</div>
</div>
<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>
{% endblock %}
{% block googlemapjs %}{% endblock %}
In my main.js there is only the code from the google example and nothing more. And in my zimmer_einstellen.html I am trying to implement the autocomplete function:
{% extends "basic.html" %}
{% block content %}
<div class = "container zimmer_einstellen">
<table id="address">
<tr>
<td class="label">Street address</td>
<td class="slimField"><input class="field" id="street_number"
disabled="true"></input></td>
<td class="wideField" colspan="2"><input class="field" id="route"
disabled="true"></input></td>
</tr>
<tr>
<td class="label">City</td>
<td class="wideField" colspan="3"><input class="field" id="locality"
disabled="true"></input></td>
</tr>
<tr>
<td class="label">State</td>
<td class="slimField"><input class="field"
id="administrative_area_level_1" disabled="true"></input></td>
<td class="label">Zip code</td>
<td class="wideField"><input class="field" id="postal_code"
disabled="true"></input></td>
</tr>
<tr>
<td class="label">Country</td>
<td class="wideField" colspan="3"><input class="field"
id="country" disabled="true"></input></td>
</tr>
</table>
</div>
{% endblock %}
{% block googlemapjs %}<script src="https://maps.googleapis.com/maps/api/js?key=HEREISAPIKEY&libraries=places&callback=initAutocomplete"
async defer></script>{% endblock %}
I have already tryed so many possibilities to implement it in flask but nothing worked, the code itself is okay because on a single html page it works fine. What am I missing?
EDIT:
I just tested a simple alert() function onload, which didnt worked aswell, so jQuery is not recognized at all, but the path is correct (I inspected the path via HTML view in browser)
EDIT 2:
Okay so the problem is weird, my jQuery is only recognized on the basic.html itself but on none of the pages which extend the basic html. How do I fix this?