jQuery UI Autocomplete Formatting for Multiple Elements

前端 未结 3 535
渐次进展
渐次进展 2021-01-06 10:23

I have the jQuery UI Autocomplete setup to my liking and working perfectly, but there is one fatal flaw. In my autocomplete I use a custom display like this example. I hav

3条回答
  •  猫巷女王i
    2021-01-06 11:07

    You simply need to override the function via the object prototype, instead of on a single instance.

    $.ui.autocomplete.prototype._renderItem = function( ul, item ) {
      return $( '
  • ' ) .data( 'item.autocomplete', item ) .append( '' + item.label + '
    ' + item.desc + '
    ' ) .appendTo( ul ); };

    Overwrite the function before activating any autocompletes, but after the script has loaded.

提交回复
热议问题