]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Render items as text, not HTML. Fixes #5275 - suggestions are not html...
authorScott González <scott.gonzalez@gmail.com>
Mon, 19 Jul 2010 19:45:30 +0000 (15:45 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 19 Jul 2010 19:45:30 +0000 (15:45 -0400)
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.

demos/autocomplete/combobox.html
demos/autocomplete/search.php
ui/jquery.ui.autocomplete.js

index 10d16539202d89269f6dc03233959144c080e635..4cc98d8f98892f7f88cc3a627793ae94fb044d1d 100644 (file)
                                                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>&nbsp;</button>")
                                .attr("tabIndex", -1)
                                .attr("title", "Show All Items")
index 01206489a13880eaecbaf4a2344e224dccf88eaa..8fa9d28f818a31f81501f62cac730ce1b2784d81 100644 (file)
@@ -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",
index c25a8884f266599add3ec564713ab978cbb44b02..27bfe941c8e96b88b1ac3ecdd3877e52316e4400 100644 (file)
@@ -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 );
        },