mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Autocomplete: Render items as text, not HTML. Fixes #5275 - suggestions are not html-encoded.
As noted in the ticket, it's probably better to default to unstyled items to prevent problems. Users can still implement their own rendering method as shown in the custom data and display demo.
This commit is contained in:
parent
7deb873c51
commit
1f2cfb942f
@ -54,6 +54,12 @@
|
||||
minLength: 0
|
||||
})
|
||||
.addClass("ui-widget ui-widget-content ui-corner-left");
|
||||
input.data("autocomplete")._renderItem = function( ul, item) {
|
||||
return $( "<li></li>" )
|
||||
.data( "item.autocomplete", item )
|
||||
.append( "<a>" + item.label + "</a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
$("<button> </button>")
|
||||
.attr("tabIndex", -1)
|
||||
.attr("title", "Show All Items")
|
||||
|
@ -3,8 +3,8 @@
|
||||
$q = strtolower($_GET["term"]);
|
||||
if (!$q) return;
|
||||
$items = array(
|
||||
"Great <em>Bittern</em>"=>"Botaurus stellaris",
|
||||
"Little <em>Grebe</em>"=>"Tachybaptus ruficollis",
|
||||
"Great Bittern"=>"Botaurus stellaris",
|
||||
"Little Grebe"=>"Tachybaptus ruficollis",
|
||||
"Black-necked Grebe"=>"Podiceps nigricollis",
|
||||
"Little Bittern"=>"Ixobrychus minutus",
|
||||
"Black-crowned Night Heron"=>"Nycticorax nycticorax",
|
||||
|
2
ui/jquery.ui.autocomplete.js
vendored
2
ui/jquery.ui.autocomplete.js
vendored
@ -304,7 +304,7 @@ $.widget( "ui.autocomplete", {
|
||||
_renderItem: function( ul, item) {
|
||||
return $( "<li></li>" )
|
||||
.data( "item.autocomplete", item )
|
||||
.append( "<a>" + item.label + "</a>" )
|
||||
.append( $( "<a></a>" ).text( item.label ) )
|
||||
.appendTo( ul );
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user