Skip to content

Commit 9d8118f

Browse files
author
Tomas Kirda
committed
Call onSearchStart and onSearchComplete for local search. Fixes #241
1 parent 66b4225 commit 9d8118f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/jquery.autocomplete.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@
533533
options.params[options.paramName] = q;
534534
params = options.ignoreParams ? null : options.params;
535535

536+
if (options.onSearchStart.call(that.element, options.params) === false) {
537+
return;
538+
}
539+
536540
if (that.isLocal) {
537541
response = that.getSuggestionsLocal(q);
538542
} else {
@@ -546,10 +550,8 @@
546550
if (response && $.isArray(response.suggestions)) {
547551
that.suggestions = response.suggestions;
548552
that.suggest();
553+
options.onSearchComplete.call(that.element, q, response.suggestions);
549554
} else if (!that.isBadQuery(q)) {
550-
if (options.onSearchStart.call(that.element, options.params) === false) {
551-
return;
552-
}
553555
if (that.currentRequest) {
554556
that.currentRequest.abort();
555557
}
@@ -572,6 +574,8 @@
572574
}).fail(function (jqXHR, textStatus, errorThrown) {
573575
options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
574576
});
577+
} else {
578+
options.onSearchComplete.call(that.element, q, result.suggestions);
575579
}
576580
},
577581

0 commit comments

Comments
 (0)