From ca698c14196ce1211cd98ba1317628bb185714ed Mon Sep 17 00:00:00 2001 From: Vyacheslav Bazhinov Date: Tue, 24 Apr 2012 18:25:35 +0700 Subject: [PATCH] Added option 'getData', which is a function returning set of data (as opposed to static 'data' option) --- doc/jquery.autocomplete.txt | 3 +++ src/jquery.autocomplete.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/jquery.autocomplete.txt b/doc/jquery.autocomplete.txt index bdddd78..ebb5da7 100644 --- a/doc/jquery.autocomplete.txt +++ b/doc/jquery.autocomplete.txt @@ -184,6 +184,9 @@ useDelimiter (default value: false) comma. For example, you may want to allow the user to enter a comma separated list of values--and each value will autocomplete without erasing the other delimited values in the input field. +getData (default value: null) + Function which return data to be processed. If several sources are present, then data is fetched + in following order: "data" option, "getData" option call, ajax query to remote url. More advanced options : ======================= diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 02fcdc2..9528dd6 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -80,7 +80,8 @@ useDelimiter: false, delimiterChar: ',', delimiterKeyCode: 188, - processData: null + processData: null, + getData: null }; /** @@ -536,6 +537,8 @@ processResults([], value); } else if (this.options.data) { processResults(this.options.data, value); + } else if (this.options.getData) { + processResults(this.options.getData(), value); } else { this.fetchRemoteData(value, function(remoteData) { processResults(remoteData, value);