Typeahead.js - 无法读取未定义的'isArray'的属性

Nea*_*alR 3 asp.net-mvc jquery asp.net-mvc-3 twitter-bootstrap typeahead.js

我试图typeahead.js在ASP MVC视图中实现自动完成/搜索,但是在Chrome的控制台中,当页面加载时我收到错误:

Uncaught TypeError: Cannot read property 'isArray' of undefined ...  typeahead.js:26
Run Code Online (Sandbox Code Playgroud)

这是它所引用的typeahead.js文件中的代码部分

    isString: function(obj) {
        return typeof obj === "string";
    },
    isNumber: function(obj) {
        return typeof obj === "number";
    },
    isArray: $.isArray, <-UncaughtTypeError: Cannor read property of 'isArray' of undefined
    isFunction: $.isFunction,
    isObject: $.isPlainObject,
    isUndefined: function(obj) {
        return typeof obj === "undefined";
    },
Run Code Online (Sandbox Code Playgroud)

这是typeahead代码以及我正在使用的声明.

<script src="http://twitter.github.io/typeahead.js/releases/latest/typeahead.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.typeahead').typeahead({
            source: function (term, process) {
                var url = '@Url.Content("~/Home/GetNames")';

                return $.getJSON(url, { term: term }, function (data) {
                    return process(data);
                });
            }
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

这是用于搜索的输入元素

            <form class="navbar-search pull-left">  
              <input type="text" value="" id="typeahead" data-provide="typeahead" class="search-query" /> @*placeholder=" Agent search" />*@  
            </form> 
Run Code Online (Sandbox Code Playgroud)

Dar*_*rov 5

反转typeheadjquery脚本定义不仅仅是第一个取决于第二个:

<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script src="http://twitter.github.io/typeahead.js/releases/latest/typeahead.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)