(function () { const element = document.getElementById('newMember').elements['user_id']; const choices = new Choices(element, { noResultsText: 'No users found', noChoicesText: 'Start typing to search users' }); element.addEventListener('search', RVR.debounce(async function (e) { RVR.httpRequest('GET', searchUserUrl.replace('QUERY', encodeURIComponent(e.detail.value)), function () { choices.setChoices(this.response.results, 'value', 'label', true); }); })); element.addEventListener('choice', function () { choices.setChoices([], 'value', 'label', true); }); })();