Fix autocomplete

This commit is contained in:
Paul Chavard 2018-08-28 11:04:44 +01:00
parent 358637adde
commit 3d506a8cdc

View file

@ -38,10 +38,12 @@ function source(url) {
addEventListener('turbolinks:load', function() { addEventListener('turbolinks:load', function() {
for (let { type, url } of sources) { for (let { type, url } of sources) {
let select = autocomplete(selector(type), options, [source(url)]); for (let target of document.querySelectorAll(selector(type))) {
select.on('autocomplete:selected', ({ target }, suggestion) => { let select = autocomplete(target, options, [source(url)]);
$(target).trigger('autocomplete:select', suggestion); select.on('autocomplete:selected', ({ target }, suggestion) => {
select.autocomplete.setVal(suggestion.label); $(target).trigger('autocomplete:select', suggestion);
}); select.autocomplete.setVal(suggestion.label);
});
}
} }
}); });