devbridge / jQuery-Autocomplete

Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields
https://www.devbridge.com/sourcery/components/jquery-autocomplete/
Other
3.56k stars 1.66k forks source link

formatResult: styling item Container? #822

Closed fuxifex closed 3 years ago

fuxifex commented 3 years ago

i read about formatResult - but how would i style the item's parent container (which would be div.autocomplete-suggestion)? i want to colorize certain items .. thanks!

tkirda commented 3 years ago

In formatResult you can wrap your item with node with custom classes based on suggestion value/data:

formatResult: function (suggestion) {
  // You can also reuse original formatResult
  return '<div class="my-class">' + this._formatResult(suggestion.value) + '</div>';
}

Currently, there is no option to style a container, but you can always use custom CSS to change styles.