Trying to get jQuery UI Autocomplete to work with data labels that may have entities in them, such as a hyphen ( - ).
I extended the function so that what shows in the suggestion list works and shows the character instead of the entity code, but cannot figure out how to make it do the same when the item is chosen and it populates the text field.
(function( $ ) {
$(function() {
var url = SQMSAutocomplete.url + "?action=sqms_auto_search";
$( "#sqms-auto-search" ).autocomplete({
source: url,
delay: 500,
minLength: 3,
select: function(event, ui){
console.log(ui.item.link)
// window.location = ui.item.url
}
})
.autocomplete( "instance" )._renderItem = function( ul, item ) {
return $( "<li>" )
.append( item.label )
.appendTo( ul );
};
});
})( jQuery );
Does that make sense?
Thank you