2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2025-03-14 21:42:21 +00:00

Add ability to specify any additional ajax settings. Fixes #223, fixes #185

This commit is contained in:
Tomas Kirda 2014-08-24 18:52:05 -05:00
parent f73c77905a
commit e33cfc8a7f
2 changed files with 11 additions and 3 deletions

View File

@ -53,6 +53,7 @@
var noop = function () { },
that = this,
defaults = {
ajaxSettings: {},
autoSelectFirst: false,
appendTo: document.body,
serviceUrl: null,
@ -521,7 +522,8 @@
options = that.options,
serviceUrl = options.serviceUrl,
params,
cacheKey;
cacheKey,
ajaxSettings;
options.params[options.paramName] = q;
params = options.ignoreParams ? null : options.params;
@ -546,12 +548,17 @@
if (that.currentRequest) {
that.currentRequest.abort();
}
that.currentRequest = $.ajax({
ajaxSettings = {
url: serviceUrl,
data: params,
type: options.type,
dataType: options.dataType
}).done(function (data) {
};
$.extend(ajaxSettings, options.ajaxSettings);
that.currentRequest = $.ajax(ajaxSettings).done(function (data) {
var result;
that.currentRequest = null;
result = options.transformResult(data);

View File

@ -13,6 +13,7 @@ The standard jquery.autocomplete.js file is around 2.7KB when minified via Closu
* Sets up autocomplete for input field(s).
* `options`: An object literal which defines the settings to use for the autocomplete plugin.
* `serviceUrl`: Server side URL or callback function that returns serviceUrl string. Optional if local lookup data is provided.
* `ajaxSettings`: Any additional [Ajax Settings](http://api.jquery.com/jquery.ajax/#jQuery-ajax-settings) that configure the jQuery Ajax request.
* `lookup`: Lookup array for the suggestions. It may be array of strings or `suggestion` object literals.
* `suggestion`: An object literal with the following format: `{ value: 'string', data: any }`.
* `lookupFilter`: `function (suggestion, query, queryLowerCase) {}` filter function for local lookups. By default it does partial string match (case insensitive).