[autocomplete] add option to allow HTML in label
I spend the last two days changing all 4 different types of fancy list controls and autocomplete functions we use to jQuery UI's autocomplete! I love that there is 1 out of the box solution for so many different situations!
The main thing I've been missing is an option that allows me to format the label used by the widget.
I have read that I can override the renderitem method, but this seems like a very very complicated solution to a very simple problem.
The render item function currently is:
- _renderItem: function( ul, item ) {
- return $( "<li>" )
- .append( $( "<a>" ).text( item.label ) )
- .appendTo( ul );
- },
what if we would
- add an option allowHTML
and change the code to:
- _renderItem: function( ul, item ) {
- if ( this.options.allowHTML == true ) {
- return $( "<li>" )
- .append( $( "<a>" ).html( item.label ) )
- .appendTo( ul );
- }else{
- return $( "<li>" )
- .append( $( "<a>" ).text( item.label ) )
- .appendTo( ul );
- }
- },
It's a simple addition, allowing 'simple' users full control over the format of the label without destroying compatibility...