javascript - autocomplete with categories and custom display -
i using jquery ui autocomplete 1.10.2 problem cannot both categories feature , custom item display work together.
this code not working
$.widget("custom.catautocomplete",$.ui.autocomplete,{ _rendermenu: function( ul, items ) { var = this, currentcategory = ""; $.each( items, function( index, item ) { if ( item.category != currentcategory ) { ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" ); currentcategory = item.category; } that._renderitem( ul, item ); }); } }); $("#search-input").autocomplete({ source:'${pagecontext. request. contextpath}/autocomplete.htm', select: function(event,ui){ var item = ui.item; $("#url-container").html(""); $("#url-container").append( "<a target='_blank' href='"+item.url+"' url='"+item.url+"' class='chosen'>"+ "<strong style='color:#1f497d' >" + item.instrument +" </strong><strong style='color: red'> " + item.func + "</strong></a><br/>" ) } }).data( "ui-autocomplete" )._renderitem = function( ul, item ) { return $( "<li>" ) .append( "<a href='#' url='"+item.url+"' class='chosen'>"+ "<strong style='color:#1f497d' >" + item.highlightedins +" </strong><strong style='color: red'> " + item.func + "</strong></a>" ) .appendto( ul ); };
the problem displays category not item, item empty link, checked find has .data function, code working pretty before make widget categories.
how can solve ?
Comments
Post a Comment