From 83116467ea317839a6659cdce6f16ea7103a0714 Mon Sep 17 00:00:00 2001 From: agrath Date: Thu, 21 Jan 2021 08:29:30 +1300 Subject: [PATCH] Add onloading/onloaded callbacks --- jquery.swiftype.autocomplete.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jquery.swiftype.autocomplete.js b/jquery.swiftype.autocomplete.js index 2c52431..fe7f066 100644 --- a/jquery.swiftype.autocomplete.js +++ b/jquery.swiftype.autocomplete.js @@ -108,6 +108,9 @@ if (handleFunctionParam(config.disableAutocomplete) === false) { $listContainer.show(); } + if (config.onLoaded) { + config.onLoaded(); + } }; $this.hideList = function(sync) { @@ -347,6 +350,10 @@ $this.showNoResults(); return; } + var config = $this.data('swiftype-config-autocomplete'); + if (config.onLoading) { + config.onLoading(); + } var cached = $this.cache.get(norm); if (cached) { processData($this, cached, term); @@ -409,7 +416,8 @@ var defaultOnComplete = function(item, prefix) { window.location = item['url']; }; - + var defaultOnLoading = function () { }; + var defaultOnLoaded = function () { }; var defaultDropdownStylesFunction = function($this) { var config = $this.data('swiftype-config-autocomplete'); var $attachEl = config.attachTo ? $(config.attachTo) : $this; @@ -552,6 +560,8 @@ noResultsClass: 'noResults', noResultsMessage: undefined, onComplete: defaultOnComplete, + onLoading: defaultOnLoading, + onLoaded: defaultOnLoaded, resultRenderFunction: defaultResultRenderFunction, renderFunction: defaultRenderFunction, dropdownStylesFunction: defaultDropdownStylesFunction,