const refSearchField = document.querySelector('#choices-refSearch'); const ajaxURL = '?type=5000'; const refSearch = new Choices(refSearchField, { renderChoiceLimit: -1, addItems: false, allowHTML: true, maxItemCount: 1, shouldSort: false, searchFloor: 2, searchResultLimit: 5, searchFields: ['customProperties.product', 'customProperties.refid', 'customProperties.budi'], placeholderValue: '', searchPlaceholderValue: '', loadingText: '', noResultsText: '', itemSelectText: '', }); refSearch.setChoices(async () => { try { const items = await fetch(ajaxURL); return items.json(); } catch (err) { console.error(err); } }); refSearchField.addEventListener( 'choice', function(event) { window.location.href = event.detail.choice.value.replace("&", "&"); });