mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-10 09:36:35 +02:00
Remove loading state if empty array passed to .ajax()
This commit is contained in:
parent
390023039a
commit
6abeb65c95
|
@ -1118,6 +1118,7 @@ class Choices {
|
|||
_ajaxCallback() {
|
||||
return (results, value, label) => {
|
||||
if (!results || !value) return;
|
||||
|
||||
const parsedResults = isType('Object', results) ? [results] : results;
|
||||
|
||||
if (parsedResults && isType('Array', parsedResults) && parsedResults.length) {
|
||||
|
@ -1133,7 +1134,11 @@ class Choices {
|
|||
this._addChoice(isSelected, isDisabled, result[value], result[label]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// No results, remove loading state
|
||||
this._handleLoadingState(false);
|
||||
}
|
||||
|
||||
this.containerOuter.removeAttribute('aria-busy');
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue