简体   繁体   English

jquery ui 自动完成功能不适用于 jquery 3.2.1 版

[英]jquery ui autocomplete doesn't work with jquery version 3.2.1

Hi I am using jquery version 3.2.1 in our projects and now i need to use jquery ui autocomplete which contains version 1.12.4.嗨,我在我们的项目中使用 jquery 3.2.1 版,现在我需要使用包含 1.12.4 版的 jquery ui 自动完成功能。 Due to this our position of autocomplete change(top and left position).因此,我们的自动完成位置更改(顶部和左侧位置)。 For this I just found a temporary solution.I calculate position dynamically through jquery and set position through jquery.为此,我刚刚找到了一个临时解决方案。我通过 jquery 动态计算位置并通过 jquery 设置位置。 But I am not sure I can get a problem in any other functionality in future.但我不确定我将来会在任何其他功能中遇到问题。 SO is there any other solution for this that works fine in all situation.所以有没有其他解决方案可以在所有情况下正常工作。 The autocomplete i am using is this我正在使用的自动完成是这个

The file in autocomplete are:自动完成中的文件是:

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

And I need to use我需要使用

<script src="https://code.jquery.com/jquery-3.2.1.js"></script>

Thanks in Advance !提前致谢!

Check this code it's working.检查此代码它正在工作。 Reference参考

 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery UI Autocomplete - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $( function() { var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; $( "#tags" ).autocomplete({ source: availableTags }); } ); </script> </head> <body> <div class="ui-widget"> <label for="tags">Tags: </label> <input id="tags"> </div> </body> </html>

I had the same problem for my input autocomplet city,我的输入自动完成城市也有同样的问题,

With the version 3, Jquery autocomplet work differently.在版本 3 中,Jquery 自动完成的工作方式有所不同。 You need to put your data before {} :您需要将数据放在 {} 之前:

<script>
  $( function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
    $( "#tags" ).autocomplete(availableTags{
      // others options
    });
  } );
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM