Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#9093 closed feature (duplicate)

Support html labels returned from source

Reported by: Skaffen Owned by:
Priority: minor Milestone: none
Component: ui.autocomplete Version: 1.10.0
Keywords: Cc:
Blocked by: Blocking:

Description

I've been trying to understand the combobox demo as I want to do something similar. That lead to me reporting http://bugs.jqueryui.com/ticket/9086 :). As part of this I've noticed that only text labels are supported. To implement highlighting of the matched substring the combobox demo monkeypatches autocomplete by replacing _renderItem which works but seems a bit nasty.

I was wondering if it would be a good feature to have _renderItem still treat "item.label" as text by default, but also allow for html labels - this would facilitate highlighting (there may be other use cases).

The two ways that spring to mind are to do one of the following in _renderItem:

  • Allow source.label to be a jquery object which _renderItem can detect and if so then it just appends that to the "<a>" instead of calling .text() with it, otherwise it continues to call .text().
  • Allow for source.htmlLabel which, if set, will be passed by _renderItem to .html() on the "<a>" instead, otherwise falling back to calling .text() with source.label

Having that would also allow for simplifying of the combobox demo (assuming the highlighting doesn't just get removed from the demo, which is one of my suggestions for dealing with bug 9086).

Change History (2)

comment:1 Changed 7 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #5918.

comment:2 Changed 7 years ago by Skaffen

Sorry for not spotting that it had already been covered - I did have a quick search! Consider me another vote then for finding modifying _renderItems to be rather monkey-patch-like and desiring core support to avoid that :).

Note: See TracTickets for help on using tickets.