2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-09-19 08:49:01 +00:00

Call onSearchStart and onSearchComplete for local search. Fixes #241

This commit is contained in:
Tomas Kirda 2014-09-21 18:00:12 -05:00
parent 66b4225e47
commit 9d8118fa6b

View File

@ -533,6 +533,10 @@
options.params[options.paramName] = q;
params = options.ignoreParams ? null : options.params;
if (options.onSearchStart.call(that.element, options.params) === false) {
return;
}
if (that.isLocal) {
response = that.getSuggestionsLocal(q);
} else {
@ -546,10 +550,8 @@
if (response && $.isArray(response.suggestions)) {
that.suggestions = response.suggestions;
that.suggest();
options.onSearchComplete.call(that.element, q, response.suggestions);
} else if (!that.isBadQuery(q)) {
if (options.onSearchStart.call(that.element, options.params) === false) {
return;
}
if (that.currentRequest) {
that.currentRequest.abort();
}
@ -572,6 +574,8 @@
}).fail(function (jqXHR, textStatus, errorThrown) {
options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
});
} else {
options.onSearchComplete.call(that.element, q, result.suggestions);
}
},