jquery 3.1.0 和 jquery-ui 自动完成不兼容,有什么解决方法? [英] jquery 3.1.0 and jquery-ui autocomplete are not compatible, what's the workaround?

查看:12
本文介绍了jquery 3.1.0 和 jquery-ui 自动完成不兼容,有什么解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让 jQuery 3.1.0 与 jQuery UI 的自动完成功能一起使用.

I am having trouble getting jQuery 3.1.0 to work with jQuery UI's autocomplete feature.

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

The only workaround I know is by replacing jQuery 3.1.0 with the one that is prepackaged with the jQUERY UI installer. Unfortunately, this wouldn't work for me as the version in the installer package of jQuery UI doesn't allow me to use tags-input and other modern features that I require for my website.

<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
        });
      } );

推荐答案

现在似乎工作正常:

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

  • jQuery 3.1.1
  • jQuery 用户界面 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>

这篇关于jquery 3.1.0 和 jquery-ui 自动完成不兼容,有什么解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆