From 535a34f12a9eea12dd7612c71dd456376d47452f Mon Sep 17 00:00:00 2001 From: Realharon Date: Fri, 21 Oct 2016 03:55:28 +0500 Subject: [PATCH 1/3] New feature for options.params Added support for use callback function instead of dictionary in options.params. This need for dynamically set custom Ajax parameters. --- src/jquery.autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 17146d25..92f487f6 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -553,7 +553,7 @@ ajaxSettings; options.params[options.paramName] = q; - params = options.ignoreParams ? null : options.params; + params = options.ignoreParams ? null : (typeof(options.params) == 'function' ? options.params.call(that.element) : options.params); if (options.onSearchStart.call(that.element, options.params) === false) { return; From 94535fe29283db51f555f229aa6485b009c8f53b Mon Sep 17 00:00:00 2001 From: Realharon Date: Fri, 21 Oct 2016 04:59:34 +0500 Subject: [PATCH 2/3] Revert "New feature for options.params" This reverts commit 535a34f12a9eea12dd7612c71dd456376d47452f. --- src/jquery.autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 92f487f6..17146d25 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -553,7 +553,7 @@ ajaxSettings; options.params[options.paramName] = q; - params = options.ignoreParams ? null : (typeof(options.params) == 'function' ? options.params.call(that.element) : options.params); + params = options.ignoreParams ? null : options.params; if (options.onSearchStart.call(that.element, options.params) === false) { return; From bf27a9955cc33fca758eca5d2353530943f03893 Mon Sep 17 00:00:00 2001 From: Realharon Date: Fri, 21 Oct 2016 05:04:37 +0500 Subject: [PATCH 3/3] New feature for options.params Added support for use callback function instead of dictionary in options.params. This need for dynamically set custom Ajax parameters. --- src/jquery.autocomplete.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 17146d25..9e0e8204 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -551,6 +551,10 @@ params, cacheKey, ajaxSettings; + + if ($.isFunction(options.params)) { + options.params = options.params.call(that.element); + } options.params[options.paramName] = q; params = options.ignoreParams ? null : options.params; @@ -559,7 +563,7 @@ return; } - if ($.isFunction(options.lookup)){ + if ($.isFunction(options.lookup)) { options.lookup(q, function (data) { that.suggestions = data.suggestions; that.suggest();