jquery自动完成显示自定义结果

我使用jQuery自动完成并尝试使用缩略图,标题和链接显示自定义结果。

但是,我有一些困难使它工作。

source: function(req, response){ $.getJSON(search_ac.url+'?callback=?&action='+acs_action, req, function( data ) { response( jQuery.map( data, function( item ) { jQuery.each( item, function( i, val ) { label = item.label; category = item.category; thumbnail = item.thumbnail; link = item.link; renderHtml = "
" + "
" + label + "
" + category + "
"; }) return $(renderHtml); })); }); },

使用return $(renderHtml) ,会出现自动完成菜单(包含正确的项目数),但其中没有显示任何内容。

使用return renderHtml ,将显示自动完成菜单,并且每个项目内显示正确的内容,但采用文本格式。 它返回这样的文字:

"

my post title
blog

"

如何从renderHtml var中显示渲染的html?

这里的工作脚本:

 .data( 'ui-autocomplete' )._renderItem = function( ul, item ) { return $( "
  • " ) .data( "item.autocomplete", item ) .append(item.value) .appendTo( ul ); };