I'm looking for some help in customizing the dropdown that displays the results of autocomplete. I have the following html which I want to use to display the results. The idea is that the div below is hidden to begin with and as soon there is a match, I make the div visible and each matched results would be wrapped in the < li > tag below.
<div class="search_dropdown_wrapper" style="display:none;">
<div id="search_arrow" class="dropdown_pointer search"></div>
<ul>
<li>
<img src="/assets/2c42cdf.jpg" />
<h4>Tom Jerry</h4>
<p>Cartoon Characters</p>
</li>
<li>
...
</li>
...
</ul>
</div>
The portion of my autocomplete code which works to display the results is..
$('#search_name').autocomplete({
minLength: 2,
...
...
})
.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.name + "</a>" )
.appendTo( ul );
};
(FYI, the above thanks to How to set-up jquery-ui autocomplete in Rails)
At the moment I only have the name (item.name) displaying in the dropdown. How can I get the html I want into the code above. The part where I'm confused is how to get the div around the ul item which is being passed into the function. Thanks.