mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2025-01-11 01:32:04 +00:00
Merge pull request #36 from jesseditson/master
Added JSONP support (via new dataType option)
This commit is contained in:
commit
3757adddbd
@ -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
|
||||
|
||||
|
@ -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;
|
||||
},
|
||||
@ -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);
|
||||
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user