Using handlebar I get this error :Uncaught TypeError: $(…).geocomplete is not a function

a 夏天 提交于 2019-12-12 03:33:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!