这是我的jQuery UI自动完成代码。它工作正常,但我想限制输出结果。我有什么方法可以做到吗?
$(document).ready(function() {
$("#company").autocomplete({
autoFocus: true,
source: '{{ url("/companySearch") }}',
minLength: 2,
select: function(event, ui) {
event.preventDefault();
$("#company").val(ui.item.label);
if (ui.item.label == 'Other') {
//loadOtherCompany();
$("#othercompany").show();
}
$('#company').val('');
$("#multipleAutoComplete").append('<div class="remvcomapny_' + ui.item.key + ' companycls"><p>' + ui.item.label + '</p><input type="hidden" name="companykeys[]" value="' + ui.item.key + '" ><a href="javascript:void(0);" onclick="removeCompanyName(\'' + ui.item.key + '\')"><i class="fa fa-times"></i></a></div>').show();
//$("#companykey").val(ui.item.key);
//getcompanyContacts(ui.item.key);
},
focus: function(event, ui) {
selectFirst: true;
event.preventDefault();
},
open: function(event, ui) {
$(this).autocomplete("widget")
.appendTo("#results").css({
'position': 'static',
'width': '100%'
});
$('.ui-autocomplete').css('z-index', '9999999');
$('.ui-autocomplete').addClass('srchuser-dropdown');
}
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("<li style='height:60px;'><span class='srchuser-downname'>" + item.label + "</span></li>").data("ui-autocomplete-item", item).appendTo(ul);
};
});