未捕获的TypeError:$(...).autocomplete不是JQuery-UI中的函数

azpvetkf  于 4个月前  发布在  jQuery
关注(0)|答案(2)|浏览(59)

在我的项目中无法识别autocomplete函数,即使我将它的ui库存储在本地磁盘中并将其导入脚本标记中。

HTML代码

<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
  <link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
  <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" />
  <link href="~/Content/Chosen/chosen.min.css" rel="stylesheet" />
  <link href="~/Scripts/jquery-ui-1.10.2.css" rel="stylesheet" />

  <script src="~/Scripts/modernizr-2.6.2.js"></script>
  <script src="~/Scripts/jquery-ui-1.10.2.js"></script>
  <script src="~/Scripts/chosen.jquery.min.js"></script>
  <script src="~/Scripts/jquery-1.10.2.js"></script>
  <script src="~/Scripts/bootstrap.min.js"></script>

字符串

jquery代码

$(document).ready(function() {
    $(document).bind('keypress', function(e) {
        if (e.keyCode == 13) {
            $('#defaultActionButton').trigger('click');
        }
    });

    $('#SearchString').keyup(function() {
        var value = $(this).val().toLowerCase();

        filter('#myTable tr', value);
    });

    function filter(idObject, srchText) {
        $(idObject).filter(function() {
            $(this).toggle($(this).text().toLowerCase().indexOf(srchText) > -1)
        });
    }

    $('#SearchString').autocomplete({
        source: '@Url.Action("SearchAutocomplete", "Student")'
    });
});

已满错误

Uncaught ReferenceError: jQuery is not defined
    at jquery-ui-1.10.2.js:314
(anonymous) @ jquery-ui-1.10.2.js:314
chosen.jquery.min.js:2 Uncaught ReferenceError: jQuery is not defined
    at chosen.jquery.min.js:2
    at chosen.jquery.min.js:2
(anonymous) @ chosen.jquery.min.js:2
(anonymous) @ chosen.jquery.min.js:2
(index):144 Uncaught TypeError: $(...).autocomplete is not a function
    at HTMLDocument.<anonymous> ((index):144)
    at fire (jquery-1.10.2.js:3062)
    at Object.fireWith [as resolveWith] (jquery-1.10.2.js:3174)
    at Function.ready (jquery-1.10.2.js:447)
    at HTMLDocument.completed (jquery-1.10.2.js:118)


我真的不知道根本原因是什么。如果你有解决方案,请帮助。

wfveoks0

wfveoks01#

将jquery.js文件放在jquery-ui.js文件之前。顺序很重要。

hiz5n14c

hiz5n14c2#

**在jquery-ui.min.js文件之前添加jquery.min.js文件。顺序很重要。**这种顺序允许jQuery UI扩展jQuery并无缝利用其功能。

相关问题