Я добавил новую js-библиотеку в свой проект (typeahead.bundle.js), и всякий раз, когда я пытаюсь вызвать любые функции, которые, по его утверждению, они не существуют. Кажется, что его ищет в JQuery вместо моей библиотеки:MVC Невозможно использовать определенные JS-библиотеки
Uncaught TypeError: $(...).typeahead is not a function
(anonymous function) @ Create:50
x.Callbacks.c @ jquery-1.10.2.min.js:21
x.Callbacks.p.fireWith @ jquery-1.10.2.min.js:21
x.extend.ready @ jquery-1.10.2.min.js:21q @ jquery-1.10.2.min.js:21
Я также нашел эту проблему с JQuery-интерфейсом.
Соответствующее использование:
<script src="/Scripts/typeahead.bundle.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#MemberSearch").typeahead({ //error line
source: function (request, response) {
$.ajax({
url: "/Operations/AutoCompleteMember",
type: "POST",
dataType: "json",
data: { term: request.term },
success: function (data) {
response($.map(data, function (item) {
return { label: item.Member, value: item.Member };
}))
}
})
},
messages: {
noResults: "", results: ""
}
});
})
</script>
...
<div class="form-group">
@Html.Label("Member Search", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBox("MemberSearch", "", htmlAttributes: new { @class = "form-control btn-group" })
<button type="button" onclick="" class="btn btn-group" aria-label="Left Align">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</button>
</div>
</div>
Вы загружены 'typeahead' библиотека? Ошибка явно не предполагает. – Satpal
@Satpal Is не хватает? Каким другим способом я могу загрузить lib? –