Merge pull request #2471 from tchak/fix-autocomplete

Fix autocomplete
This commit is contained in:
Mathieu Magnin 2018-08-28 12:17:32 +02:00 committed by GitHub
commit 5208fb2e35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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