Jquery autocomplete - custom html for result listing

前端 未结 4 1676
夕颜
夕颜 2020-12-24 12:59

I am referring to this plugin: http://jqueryui.com/demos/autocomplete/

So the original structure for the results is

4条回答
  •  孤独总比滥情好
    2020-12-24 13:24

    You need to replace the _renderItem method (for the autocomplete in question):

    $("selector").autocomplete({ ... })
       .data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); };

    (assuming the items in your source have a property called customattribute)

    As shown in this example: http://jqueryui.com/demos/autocomplete/#custom-data

提交回复
热议问题