Skip to content

Adds optional function "transformQuery" to manipulate the query #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/jquery.autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Ajax Autocomplete for jQuery, version 1.2.9
* Ajax Autocomplete for jQuery, version 1.2.10
* (c) 2013 Tomas Kirda
*
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
Expand Down Expand Up @@ -80,6 +80,9 @@
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
},
transformQuery: function(query) {
return query;
},
paramName: 'query',
transformResult: function (response) {
return typeof response === 'string' ? $.parseJSON(response) : response;
Expand Down Expand Up @@ -439,12 +442,13 @@

getQuery: function (value) {
var delimiter = this.options.delimiter,
tvalue = this.options.transformQuery(value),
parts;

if (!delimiter) {
return value;
return tvalue;
}
parts = value.split(delimiter);
parts = tvalue.split(delimiter);
return $.trim(parts[parts.length - 1]);
},

Expand Down