For my autocomplete I sort my results into 3 sections "title", "company", "tag".
I would like to have a headline for each section:
What I have: | What I aim for: |
Here is my code:
... .autocomplete( "instance" )._renderItem = function( ul, item ) { if(item.option==="title") { return $( "<li>" ) .append( "<div><i class='fas fa-tags'></i> " + item.label + "<br> title </div>" ) .appendTo( ul ); } else if(item.option==="company"){ return $( "<li>" ) .append( "<div><i class='fas fa-building'></i> " + item.label + "<br> company </div>" ) .appendTo( ul ); } else if(item.option==="tags"){ return $( "<li>" ) .append( "<div><i class='fas fa-utensils'></i> " + item.value + "<br> tags </div>" ) .appendTo( ul ); } }; });