autocomplete: fix initialization happening several times
This commit is contained in:
parent
2a6a03423f
commit
82fc017430
1 changed files with 2 additions and 4 deletions
|
@ -48,11 +48,10 @@ addEventListener('ajax:success', function() {
|
|||
function autocompleteSetup() {
|
||||
for (let { type, url } of sources) {
|
||||
for (let element of document.querySelectorAll(selector(type))) {
|
||||
if (!element.dataset.autocompleteInitialized) {
|
||||
element.removeAttribute('data-autocomplete');
|
||||
autocompleteInitializeElement(element, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function autocompleteInitializeElement(element, url) {
|
||||
|
@ -61,5 +60,4 @@ function autocompleteInitializeElement(element, url) {
|
|||
fire(target, 'autocomplete:select', suggestion);
|
||||
select.autocomplete.setVal(suggestion.label);
|
||||
});
|
||||
element.dataset.autocompleteInitialized = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue