我有以下代码:jQuery UI的自动完成功能,显示的东西时,没有结果
// Autocomplete search
$("#shop_search").autocomplete({
source: '<%= spotify_search_path(:json) %>',
minLength: 1,
select: function(event, ui) {
append_place(ui.item.name, ui.item.id, ui.item.shop_type, ui.item.address_geo, ui.item.contact, ui.item.email, ui.item.web);
$("#shop_search").val('');
}
}).data("autocomplete")._renderItem = function(ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + "<span class='autocomplete_link'>" + item.name + "</span>" + "<br />" + "<span class='autocomplete_address'>" + item.address_geo + "</span>" + "</a>")
.appendTo(ul);
$(".ui-autocomplete-loading").ajaxStart(function(){
$(this).show();
});
$(".ui-autocomplete-loading").ajaxStop(function(){
$(this).hide();
});
};
目前它只显示下拉自动完成时,有搜索结果。如果找不到任何内容,我希望它显示“找不到匹配项”。我应该在代码中添加什么?
谢谢。
这将会是更好的,如果你解释你发布的代码。 – 2012-10-27 00:11:35