mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2025-01-05 15:32:10 +00:00
Call onSearchStart and onSearchComplete for local search. Fixes #241
This commit is contained in:
parent
66b4225e47
commit
9d8118fa6b
@ -533,6 +533,10 @@
|
|||||||
options.params[options.paramName] = q;
|
options.params[options.paramName] = q;
|
||||||
params = options.ignoreParams ? null : options.params;
|
params = options.ignoreParams ? null : options.params;
|
||||||
|
|
||||||
|
if (options.onSearchStart.call(that.element, options.params) === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (that.isLocal) {
|
if (that.isLocal) {
|
||||||
response = that.getSuggestionsLocal(q);
|
response = that.getSuggestionsLocal(q);
|
||||||
} else {
|
} else {
|
||||||
@ -546,10 +550,8 @@
|
|||||||
if (response && $.isArray(response.suggestions)) {
|
if (response && $.isArray(response.suggestions)) {
|
||||||
that.suggestions = response.suggestions;
|
that.suggestions = response.suggestions;
|
||||||
that.suggest();
|
that.suggest();
|
||||||
|
options.onSearchComplete.call(that.element, q, response.suggestions);
|
||||||
} else if (!that.isBadQuery(q)) {
|
} else if (!that.isBadQuery(q)) {
|
||||||
if (options.onSearchStart.call(that.element, options.params) === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (that.currentRequest) {
|
if (that.currentRequest) {
|
||||||
that.currentRequest.abort();
|
that.currentRequest.abort();
|
||||||
}
|
}
|
||||||
@ -572,6 +574,8 @@
|
|||||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||||
options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
|
options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
options.onSearchComplete.call(that.element, q, result.suggestions);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user