rvr-nextgen/public/static/js/communities/community_members.js
Pőcze Bence 5053d37388
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good
RVRNEXT-30 initialize TomSelect in community_members.js
2023-05-02 02:22:57 +02:00

32 lines
869 B
JavaScript

(function () {
const element = document.getElementById('newMember').elements['user_id'];
const select = new TomSelect(element, {
placeholder: 'User',
valueField: 'value',
labelField: 'label',
searchField: 'label',
loadThrottle: 300,
load: function (query, callback) {
var self = this;
RVR.httpRequest('GET', searchUserUrl.replace('QUERY', encodeURIComponent(query)), function () {
self.clearOptions();
callback(this.response.results);
});
},
});
select.on('change', function (value) {
this.clearOptions();
});
select.on('blur', function (value) {
this.clearOptions();
});
select.on('type', function (value) {
if (value === '') {
this.clearOptions();
}
});
})();