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
|
minLength: 0
|
||||||
})
|
})
|
||||||
.addClass("ui-widget ui-widget-content ui-corner-left");
|
.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>")
|
$("<button> </button>")
|
||||||
.attr("tabIndex", -1)
|
.attr("tabIndex", -1)
|
||||||
.attr("title", "Show All Items")
|
.attr("title", "Show All Items")
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
$q = strtolower($_GET["term"]);
|
$q = strtolower($_GET["term"]);
|
||||||
if (!$q) return;
|
if (!$q) return;
|
||||||
$items = array(
|
$items = array(
|
||||||
"Great <em>Bittern</em>"=>"Botaurus stellaris",
|
"Great Bittern"=>"Botaurus stellaris",
|
||||||
"Little <em>Grebe</em>"=>"Tachybaptus ruficollis",
|
"Little Grebe"=>"Tachybaptus ruficollis",
|
||||||
"Black-necked Grebe"=>"Podiceps nigricollis",
|
"Black-necked Grebe"=>"Podiceps nigricollis",
|
||||||
"Little Bittern"=>"Ixobrychus minutus",
|
"Little Bittern"=>"Ixobrychus minutus",
|
||||||
"Black-crowned Night Heron"=>"Nycticorax nycticorax",
|
"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) {
|
_renderItem: function( ul, item) {
|
||||||
return $( "<li></li>" )
|
return $( "<li></li>" )
|
||||||
.data( "item.autocomplete", item )
|
.data( "item.autocomplete", item )
|
||||||
.append( "<a>" + item.label + "</a>" )
|
.append( $( "<a></a>" ).text( item.label ) )
|
||||||
.appendTo( ul );
|
.appendTo( ul );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user