Remove loading state if empty array passed to .ajax()

This commit is contained in:
Josh Johnson 2017-02-10 09:01:20 +00:00
parent 390023039a
commit 6abeb65c95

View file

@ -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');
};
}