1

This is my jQuery UI autocomplete code. It's working correctly, but I want to limit the output results. Is there any way I can do that?

$(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);
  };
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339

0 Answers0