Skip to main content

Search and Top Navigation

#9093 closed feature (duplicate)

Opened February 18, 2013 09:09AM UTC

Closed February 18, 2013 12:45PM UTC

Last modified February 18, 2013 01:24PM UTC

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).

Attachments (0)
Change History (2)

Changed February 18, 2013 12:45PM UTC by scottgonzalez comment:1

resolution: → duplicate
status: newclosed

Duplicate of #5918.

Changed February 18, 2013 01:24PM UTC by Skaffen comment:2

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 :).