31 lines
848 B
JavaScript
31 lines
848 B
JavaScript
|
(function () {
|
||
|
const element = document.getElementById('transactionForm').elements['event_id'];
|
||
|
const select = new TomSelect(element, {
|
||
|
valueField: 'value',
|
||
|
labelField: 'label',
|
||
|
searchField: 'label',
|
||
|
loadThrottle: 300,
|
||
|
load: function (query, callback) {
|
||
|
var self = this;
|
||
|
RVR.httpRequest('GET', searchEventUrl.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();
|
||
|
}
|
||
|
});
|
||
|
})();
|