Thursday, April 9, 2015

Jquery UI Autocomplete with vertical scrollbar

scrollable dropdown instead of a plain dropdown list

bindDealerNameAC('#idDealer');

function bindDealerNameAC(idToBind) {
  $(idToBind).autocomplete({
    minLength: 1,
    create: function( event, ui ) {
      $('.ui-autocomplete').css({
        'max-height': '300px',
        'overflow-y': 'auto',
        'overflow-x': 'hidden',
      });
    },
    //source: ["choice 1", "choice"],
    source: function( request, response ) {
      $.get('/bg/crm/js_dealerarr', request, function(dataObj) {
        if (dataObj.status == true) {
          response(dataObj.dealerNameArr);
        }
        else {
          response([]);
        }
      }, 'json');
    },
  });
}

No comments: