David
David

Reputation: 20073

jQuery "autocomplete is not a function"

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>

Upvotes: 0

Views: 5370

Answers (3)

Anthony Graglia
Anthony Graglia

Reputation: 5435

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.

Upvotes: 0

ariel
ariel

Reputation: 16140

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

See it for yourself.

After fixing it, read the documentation again.

Upvotes: 1

xkeshav
xkeshav

Reputation: 54050

If you are using jQuery then do below is best practice

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

Upvotes: 0

Related Questions