Skip to content

Commit

Permalink
Version 1.7.5
Browse files Browse the repository at this point in the history
- Added the possibility to process the data from ajax request.
  • Loading branch information
running-coder committed Nov 30, 2014
1 parent 7d15271 commit 48c52b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions jquery.typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* jQuery Typeahead
*
* @author Tom Bertrand
* @version 1.7.3 (2014-11-24)
* @version 1.7.5 (2014-11-30)
*
* @copyright
* Copyright (C) 2014 RunningCoder.
Expand Down Expand Up @@ -159,7 +159,7 @@
options.debug && window.Debug.log({
'node': node.selector,
'function': 'extendOptions()',
'arguments': "{options.source}",
'arguments': "{options.source: " + JSON.stringify(options[option]) + "}",
'message': 'ERROR - source.group.url or source.group.data is Required'
});
}
Expand Down Expand Up @@ -190,7 +190,7 @@
// {/debug}

// {debug}
if (!options[option][group].url && !options[option][group].data) {
if (!options[option][group].url && !options[option][group].data && !(options[option][group] instanceof Array)) {
options.debug && window.Debug.log({
'node': node.selector,
'function': 'extendOptions()',
Expand Down Expand Up @@ -961,7 +961,7 @@

if (!options.source[group].data && !options.source[group].url) {

if (typeof options.source[group] === "string") {
if (typeof options.source[group] === "string" || options.source[group] instanceof Array) {
options.source[group] = {
url: options.source[group]
};
Expand Down Expand Up @@ -1063,10 +1063,15 @@
ajaxTimestamp: timestamp
}, ajaxObj)).done( function(data) {

// Only process the data from the latest generate
if (this.ajaxTimestamp !== timestamp) {
return false;
}

if (typeof this.process === "function") {
data = this.process(data);
}

_request.set(url, data);
_request.processQueue(url);

Expand Down

0 comments on commit 48c52b4

Please sign in to comment.