Skip to main content

Search and Top Navigation

#5918 closed enhancement (wontfix)

Opened August 10, 2010 04:03PM UTC

Closed August 17, 2010 09:06PM UTC

Last modified February 18, 2013 12:45PM UTC

Using HTML in Autocomplete

Reported by: pauleee Owned by:
Priority: minor Milestone:
Component: ui.autocomplete Version: 1.8.4
Keywords: Cc:
Blocked by: Blocking:
Description

It's not possible to use HTML in the suggestion.

File: jquery.ui.autocomplete.js

Line: 324-329

Original:

_renderItem: function( ul, item) {

return $( "<li></li>" )

.data( "item.autocomplete", item )

.append( $( "<a></a>" ).text( item.label ) )

.appendTo( ul );

}

Fixed:

_renderItem: function( ul, item) {

return $( "<li></li>" )

.data( "item.autocomplete", item )

.append( $( "<a></a>" ).html( item.label ) )

.appendTo( ul );

}

Attachments (0)
Change History (8)

Changed August 10, 2010 04:15PM UTC by rdworth comment:1

resolution: → wontfix
status: newclosed

This change is by design ( see #5275 ). As mentioned over there, "Defaulting to plaintext and defining your own render method for HTML and other complex displays makes sense."

An extension can provide a custom _renderItem, such as http://jqueryui.com/demos/autocomplete/custom-data.html so no change to the default is required.

Changed August 17, 2010 08:48PM UTC by carpeliam comment:2

Is there perhaps a middle-of-the-road longterm solution? I understand that plaintext makes for a good default, but using _renderItem smells like monkey-patching to me. It's an undocumented method (outside of examples) as far as I can tell, it requires the plugin user to know something about the implementation of the plugin (I need to be aware that ULs and LIs are being used under the hood), and doesn't feel very forward-compatible.

Perhaps an option can be added to the plugin for rendering in html?

Changed August 17, 2010 08:48PM UTC by carpeliam comment:3

resolution: wontfix
status: closedreopened

Changed August 17, 2010 09:06PM UTC by scottgonzalez comment:4

resolution: → wontfix
status: reopenedclosed

Changed August 17, 2010 09:26PM UTC by carpeliam comment:5

Thanks Scott, that's by far a much easier solution to work with. However, I'd love to see this rolled into the jqueryui codebase, just in case jqueryui implementation details change in the future, breaking this code.

Changed December 15, 2010 06:40PM UTC by scottgonzalez comment:6

#6753 is a duplicate of this ticket.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:7

milestone: TBD

Milestone TBD deleted

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

#9093 is a duplicate of this ticket.