Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The standard jquery.autocomplete.js file is around 2.7KB when minified via Closu
* `transformResult`: `function(response) {}` called after the result of the query is ready. Converts the result into response.suggestions format.
* `autoSelectFirst`: if set to `true`, first item will be selected when showing suggestions. Default value `false`.
* `appendTo`: container where suggestions will be appended. Default value `body`. Can be jQuery object, selector or html element. Make sure to set `position: absolute` or `position: relative` for that element.
* `dataType`: type of data returned from server. Either 'text' (default) or 'jsonp', which will cause the autocomplete to use jsonp. You may return a json object in your callback when using jsonp.

##Usage

Expand Down
5 changes: 3 additions & 2 deletions src/jquery.autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
onSearchComplete: noop,
containerClass: 'autocomplete-suggestions',
tabDisabled: false,
dataType : 'text',
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
},
Expand Down Expand Up @@ -406,7 +407,7 @@
url: options.serviceUrl,
data: options.params,
type: options.type,
dataType: 'text'
dataType: options.dataType
}).done(function (txt) {
that.processResponse(txt);
options.onSearchComplete.call(that.element, q);
Expand Down Expand Up @@ -476,7 +477,7 @@

processResponse: function (text) {
var that = this,
response = $.parseJSON(text);
response = typeof text == 'string' ? $.parseJSON(text) : text;

response.suggestions = that.verifySuggestionsFormat(that.options.transformResult(response));

Expand Down