Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created November 21, 2010 07:31
Show Gist options
  • Save rgrove/708539 to your computer and use it in GitHub Desktop.
Save rgrove/708539 to your computer and use it in GitHub Desktop.
/**
* Default resultListLocator used when a string-based YQL source is set and
* the implementer hasn't already specified one.
*
* @method _defaultYQLLocator
* @param {Object} response YQL response object.
* @return {Array}
* @protected
* @for AutoCompleteBase
*/
_defaultYQLLocator: function (response) {
var results = response && response.query && response.query.results,
values;
if (results && Lang.isObject(results)) {
// If there's only a single value on YQL's results object, that
// value almost certainly contains the array of results we want. If
// there are 0 or 2+ values, then the values themselves are most
// likely the results we want.
values = Y.Object.values(results) || [];
results = values.length === 1 ? values[0] : values;
if (!Lang.isArray(results)) {
results = [results];
}
} else {
results = [];
}
return results;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment