开发者

jQuery "autocomplete is not a function"

开发者 https://www.devze.com 2023-03-04 15:37 出处:网络
I\'ve seen a few different questions on this but I can\'t seem to find a solution that would fit mine.I\'m using the following code (using the UWA widget framework) and I always receive the message \"

I've seen a few different questions on this but I can't seem to find a solution that would fit mine. I'm using the following code (using the UWA widget framework) and I always receive the message "autocomplete is not a function". I am calling the autocomplete.js file so I'm not sure why I still get this message.

    <html>
    <title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
  <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css" type="text/css" />
  <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css" type="text/css" />
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js"></script>
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js"></script>
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js"></script>
  <script>
       <![CDATA[
  开发者_运维知识库    widget.onLoad = function(){
      var data = "apple pears bears bananas".split(" ");
    $("#search").autocomplete(data);
  };
  ]]>
  </script>

</head>
   <body>
     My name: <input id="search" />
   </body>
</html>


dev.jquery.com don't allow hotlinking. Host the files somewhere else.

See it for yourself.

After fixing it, read the documentation again.


If you are using jQuery then do below is best practice

$(document).ready(function () {
// write your code here    
});


Include jQuery UI too. Remove the other references and just get this working first... Also, the order of js file references can also make a difference.

DiEcho's answer is also valid though... you should always wrap it in that if you want it to load when the page is ready.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号