我用户jquery autocomplete
获取一些结果并显示结果,但是当我单击侧面时无法关闭返回结果的下拉菜单。
$(function () {
$("#search").autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("TestAutoComplete", "Home")', type: "POST", dataType: "json",
data: { query: request.term },
success: function (data) {
response($.map(data, function (item) {
return {
label: item.Title
};
}));
}
});
},
minLength: 1,
select: function (event, ui) {
onItemSelect(ui.item);
},
open: function () {
$(this).removeClass('ui-corner-all').addClass('ui-corner-top');
$(this).autocomplete('widget').css('z-index', 999999);
},
close: function () {
$(this).removeClass('ui-corner-top').addClass('ui-corner-all');
}
})
.data('ui-autocomplete')._renderItem = function (ul, item) {
return $('<li>')
.data('autocomplete-item', item)
.append('<a href="#"><p >' + item.label + "</p></a>")
.appendTo(ul);
};
});