【发布时间】:2018-07-17 13:55:44
【问题描述】:
我关注这个网站:https://github.com/biggora/bootstrap-ajax-typeahead
我将输入文本创建为:
<div class="col-xs-2">
<input type="text" class="form-control typeahead" name="user" id="user" placeholder="autocomplete" />
</div>
在我的 JS 脚本中:
$('#user').on("输入", function () { var login = $("#user").val();
$.ajax({
type: "POST",
async: false,
cache: false,
url: "/user/ajaxSearch",
data: 'login=' + login,
dataType: 'json',
success: function(data) {
var typeaheadSource = ['John', 'Alex', 'Terry'];
$('.typeahead').typeahead(typeaheadSource);
}
});
});
我没有错误,但没有列表显示。我调试了我的代码,并且调用了 typeahead 函数。
你有什么想法吗?
谢谢
【问题讨论】:
-
好的,我忘记了 typeahead 函数的属性“source”。现在我在 typeahead.js 上有这个错误: Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
标签: jquery twitter-bootstrap-3 typeahead.js