mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Disable server-side autocompletion when acSource
is not set
This commit is contained in:
parent
f84e358eec
commit
8d2c082413
1 changed files with 4 additions and 2 deletions
|
@ -171,6 +171,8 @@ function showAutocomplete(suggestions, fetchedTerm, targetInput) {
|
|||
}
|
||||
|
||||
function getSuggestions(term) {
|
||||
// In case source URL was not given at all, do not try sending the request.
|
||||
if (!inputField.dataset.acSource) return [];
|
||||
return fetch(`${inputField.dataset.acSource}${term}`).then(response => response.json());
|
||||
}
|
||||
|
||||
|
@ -241,9 +243,9 @@ function listenAutocomplete() {
|
|||
originalTerm = inputField.value;
|
||||
|
||||
const fetchedTerm = inputField.value;
|
||||
const {ac, acMinLength} = inputField.dataset;
|
||||
const {ac, acMinLength, acSource} = inputField.dataset;
|
||||
|
||||
if (ac && (fetchedTerm.length >= acMinLength)) {
|
||||
if (ac && acSource && (fetchedTerm.length >= acMinLength)) {
|
||||
if (cache[fetchedTerm]) {
|
||||
showAutocomplete(cache[fetchedTerm], fetchedTerm, event.target);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue