Skip to content

Commit

Permalink
pkp/pkp-lib@9973 Prevent multiple API calls when user type multiple c…
Browse files Browse the repository at this point in the history
…haracters (pkp#353)
  • Loading branch information
jardakotesovec authored May 21, 2024
1 parent 2b23e57 commit ec72d49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/Form/fields/FieldControlledVocab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default {
return {
allSuggestions: [],
suggestionsLoaded: false,
suggestionsLoading: false,
allowCustom: true,
};
},
Expand All @@ -21,6 +22,9 @@ export default {
this.suggestions = [];
return;
}
if (this.suggestionsLoading) {
return;
}
if (!this.suggestionsLoaded) {
this.loadSuggestions(this.setSuggestions);
}
Expand All @@ -31,6 +35,7 @@ export default {
* Load suggestions from the API
*/
loadSuggestions(successCallback) {
this.suggestionsLoading = true;
$.ajax({
url: this.apiUrl,
type: 'GET',
Expand All @@ -47,6 +52,7 @@ export default {
};
});
this.suggestionsLoaded = true;
this.suggestionsLoading = false;
if (successCallback) {
successCallback.apply(this);
}
Expand Down

0 comments on commit ec72d49

Please sign in to comment.