jquery 3.1.0和jquery-ui自动完成不兼容,解决方法是什么?

时间:2016-09-07 13:49:58

标签: jquery jquery-ui autocomplete

我无法让jQuery 3.1.0使用jQuery UI的自动完成功能。

我所知道的唯一解决方法是将jQuery 3.1.0替换为使用jquERY UI安装程序预先打包的那个。不幸的是,这对我来说不起作用,因为jQuery UI安装程序包中的版本不允许我使用我的网站所需的标签输入和其他现代功能。

<input type="email" id="tags" class="form-control" placeholder="Any Criteria" data-role="tagsinput">

<script type="text/javascript" src="external/jquery/js/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="external/jquery-ui/js/jquery-ui.min.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
        });
      } );

2 个答案:

答案 0 :(得分:5)

现在似乎工作得很好:

https://jsfiddle.net/jphellemons/0ukbtgs4/

  • jQuery 3.1.1
  • jQuery ui 1.12.1

代码:

<input type="email" id="tags" placeholder="Any Criteria">
<script type="text/javascript" src="external/jquery/js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="external/jquery-ui/js/jquery-ui-1.12.1.min.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>

答案 1 :(得分:0)

  • jQuery 3.1.1
  • jQuery ui 1.12.1
{{1}}