autocomplete UI: can't select rows with custom HTML

autocomplete UI: can't select rows with custom HTML

Hi Guys


I've overridden the _renderMenu and _renderItem functions in the autocomplete UI based on a  suggestion here:  Quick example of multi-column results with jQueryUI's new Autocomplete?  so I can implement an HTML table showing the autocomplete suggestions. It displays fine, but I can no longer click any rows or even highlight/navigate with the arrows. Can anyone suggest what might ber wrong /missing? 

  1. $(document).ready(function() {
  2.   $.ui.autocomplete.prototype._renderMenu = function(ul, items) {
  3.   var self = this;
  4.   ul.append("<table><thead><tr><th>HIN</th><th style='text-align: left;'>Description</th></tr></thead><tbody></tbody></table>");
  5.   $.each( items, function( index, item ) {
  6. self._renderItem( ul.find("table tbody"), item );
  7.   });
  8.   };
  9.   $.ui.autocomplete.prototype._renderItem = function(table, item) {
  10. return $( "<tr></tr>" )
  11. .data( "item.autocomplete", item )
  12. .append( "<td>"+item.hin+"</td>"+"<td>"+item.value+"</td>" )
  13. .appendTo( table );
  14. };
  15. $("input#sku").autocomplete(
  16. {
  17. source: "search.php?a=0&b=1",
  18. minLength: 3
  19. }
  20. );
  21. });

Many thanks
    • Topic Participants

    • lucas