问题
I am using this html code that I am trying to implement onto my handlebar file. While it works on the html/javascript file, I can't get it to work in the handlebar file.
When I use it in the handlebar, I get this error : Uncaught TypeError: $(...).geocomplete is not a function
I am putting the code into main.handlebar:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/jquery.geocomplete.js"></script>
<script language = "javascript">
$(function(){
$("#geocomplete").geocomplete().bind("geocode:result", function(event, result){
$.log("Result: " + result.formatted_address);
})
.bind("geocode:error", function(event, status){
$.log("ERROR: " + status);
})
.bind("geocode:multiple", function(event, results){
$.log("Multiple: " + results.length + " results found");
});
});
</script>
and it is not recognizing .geocomplete() method that is in js/jquery.geocomplete.js
It recognizes it in a html file though.
回答1:
Get your API key for Google Maps JavaScript API and place your API key like
<script src="https://maps.googleapis.com/maps/api/jskey=API_KEY_HERE&libraries=places"></script>
来源:https://stackoverflow.com/questions/35442804/using-handlebar-i-get-this-error-uncaught-typeerror-geocomplete-is-not