I am trying to implement the typeahead.js
autocomplete/search in an ASP MVC view but, in Chrome's Console, when the page loads I am receiving the error:
Uncaught TypeError: Cannot read property 'isArray' of undefined ... typeahead.js:26
This is the section of code in the typeahead.js file it is referring to
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";
},
Here is the typeahead
code along with the declarations I am using.
<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>
And here is the input element being used for the search
<form class="navbar-search pull-left">
<input type="text" value="" id="typeahead" data-provide="typeahead" class="search-query" /> @*placeholder=" Agent search" />*@
</form>