У меня есть следующий код
$autocompleteSearchInput.each(function() {
const $that = $(this);
$that.autocomplete({
minChars: 4,
serviceUrl: '/internals/site-search',
dataType: 'json',
paramName: 'search_string',
groupBy: 'category',
transformResult: function(response) {
return {
suggestions: $.map(response.results, function(value) {
let node = JSON.parse(value);
let title = (typeof node.field_title !== 'undefined') ? node.field_title[0].value : node.title[0].value;
let data = (typeof node.uri !== 'undefined') ? node.uri : node.path[0].alias;
let type = (node.type[0].target_id === 'property') ? 'Properties' : 'Other Results';
return {
value: title,
data: {
data:data,
category: type
}
};
})
};
},
onSearchComplete: function(query, suggestions) {
if(suggestions.length > 0) {
// add autocomplete-active class to the input when dropdown is show (remove radius on bottom corners)
$that.addClass('autocomplete-active');
}
},
onHint: function(hint) {
return false;
},
onHide: function() {
$that.removeClass('autocomplete-active');
},
onSelect: function (suggestion) {
// If selecting an individual item, direct the user to the node directly
window.location.href = suggestion.data;
}
});
});
При использовании следующих категорий кодов всегда показывать заголовки категорий.Как я могу сделать так, чтобы, если набор данных содержит только «другие результаты» или «свойства», мы не показываем заголовок?