我尝试做多个自动完成下拉框
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="~/Scripts/jquery-2.1.1.js"></script>
<script src="~/Scripts/jquery-ui-1.10.4.js"></script>
$("#discUsers")
// don't navigate away from the field on tab when selecting an item
.bind("keydown", function (event) {
if (event.keyCode === $.ui.keyCode.TAB &&
$(this).autocomplete("instance").menu.active) {
event.preventDefault();
}
})
**.autocomplete** ({
minLength: 0,
source: function (request, response) {
// delegate back to autocomplete, but extract the last term
response($.ui.autocomplete.filter(
availableTags, extractLast(request.term)));
},
focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
return false;
}
});
});
我有问题,当我运行代码时,在控制台中写我未定义不是粗体文本的函数
答案 0 :(得分:1)
您的代码前缺少<script>
标记。
答案 1 :(得分:0)
听起来像你有一个自定义版本的jQuery UI,它不包含 autocomplete 小部件的功能。
下载jQuery UI时,请确保选中自动填充小部件:jQuery UI Download Page。