我最终手动覆盖了_renderMenu and _renderItem毕竟功能。到目前为止,效果就像一个魅力,而且实际上very很容易做到。我希望有一个“每个实例”的解决方案,但当我们遇到它时,我们就会烧毁这座桥梁。这就是结果,再次感谢!
$.ui.autocomplete.prototype._renderMenu = function(ul, items) {
var self = this;
ul.append("<table><thead><tr><th>ID#</th><th>Name</th><th>Cool Points</th></tr></thead><tbody></tbody></table>");
$.each( items, function( index, item ) {
self._renderItem( ul.find("table tbody"), item );
});
};
$.ui.autocomplete.prototype._renderItem = function(table, item) {
return $( "<tr></tr>" )
.data( "item.autocomplete", item )
.append( "<td>"+item.id+"</td>"+"<td>"+item.value+"</td>"+"<td>"+item.cp+"</td>" )
.appendTo( table );
};
$("#search").autocomplete({
source: [
{id:1,value:"Thomas",cp:134},
{id:65,value:"Richard",cp:1743},
{id:235,value:"Harold",cp:7342},
{id:982,value:"Nina",cp:21843},
{id:724,value:"Pinta",cp:35},
{id:78,value:"Santa Maria",cp:787}],
minLength: 1
});