开发者

Why auto-complete from jquery does not work?

Today I started to use JQuery. I found this explanation of how to do it.

On that page I also have a complete code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <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/jquer开发者_Go百科y.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>
  $(document).ready(function(){
    var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
$("#example").autocomplete(data);
  });
  </script>

</head>
<body>
  API Reference: <input id="example" /> (try "C" or "E")
</body>
</html>

I copy paste the code and it does not work. I have to mention that it works if I try it on the page that I have mentioned before (so JavaScripts are switched on in my browser).

I have to idea how to solve this problem because I have no error message and has no previous experience with the jquery. Can anybody help me with that?

ADDED:

I found a feature that can be important. When I load the above mentioned code/page, the auto-complete works as it is expected! If I reload the page, it change its appearance a bit (a space between the input field and top of the page appears) and auto-complete stops to work. Does it tell you something?


It's because it should be: $("#example").autocomplete({ source: data })

It seems the docs you found is outdated. A more up to date version can be found here: http://jqueryui.com/demos/autocomplete/


try .split(",")

 var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ,");

also attach a sorce

$("#example").autocomplete({
                    source: data
                });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜