Tôi đã đoạn mã sau:jQuery UI autocomplete, hiển thị một cái gì đó khi không có kết quả
// 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();
});
};
Hiện nay nó chỉ cho thấy sự sụt giảm xuống autocomplete khi có kết quả tìm kiếm. Tôi muốn nó hiển thị "Không tìm thấy kết quả phù hợp" khi không tìm thấy gì. Tôi nên thêm gì vào mã?
Cảm ơn.
Nó muốn được thậm chí tốt hơn nếu bạn giải thích đoạn code bạn được đăng. –