Skip to content

Commit e33cfc8

Browse files
author
Tomas Kirda
committed
Add ability to specify any additional ajax settings. Fixes devbridge#223, fixes devbridge#185
1 parent f73c779 commit e33cfc8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

dist/jquery.autocomplete.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
var noop = function () { },
5454
that = this,
5555
defaults = {
56+
ajaxSettings: {},
5657
autoSelectFirst: false,
5758
appendTo: document.body,
5859
serviceUrl: null,
@@ -521,7 +522,8 @@
521522
options = that.options,
522523
serviceUrl = options.serviceUrl,
523524
params,
524-
cacheKey;
525+
cacheKey,
526+
ajaxSettings;
525527

526528
options.params[options.paramName] = q;
527529
params = options.ignoreParams ? null : options.params;
@@ -546,12 +548,17 @@
546548
if (that.currentRequest) {
547549
that.currentRequest.abort();
548550
}
549-
that.currentRequest = $.ajax({
551+
552+
ajaxSettings = {
550553
url: serviceUrl,
551554
data: params,
552555
type: options.type,
553556
dataType: options.dataType
554-
}).done(function (data) {
557+
};
558+
559+
$.extend(ajaxSettings, options.ajaxSettings);
560+
561+
that.currentRequest = $.ajax(ajaxSettings).done(function (data) {
555562
var result;
556563
that.currentRequest = null;
557564
result = options.transformResult(data);

readme.md

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

0 commit comments

Comments
 (0)