|
@@ -538,14 +538,17 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
|
var isFunc = $.isFunction(data);
|
|
|
return function (query) {
|
|
|
var t = query.term, filtered = {results: []};
|
|
|
- $(isFunc ? data() : data).each(function () {
|
|
|
- var isObject = this.text !== undefined,
|
|
|
- text = isObject ? this.text : this;
|
|
|
- if (t === "" || query.matcher(t, text)) {
|
|
|
- filtered.results.push(isObject ? this : {id: this, text: this});
|
|
|
- }
|
|
|
- });
|
|
|
- query.callback(filtered);
|
|
|
+ var result = $(isFunc ? data(query) : data);
|
|
|
+ if ($.isArray(result)) {
|
|
|
+ $(isFunc ? data() : data).each(function () {
|
|
|
+ var isObject = this.text !== undefined,
|
|
|
+ text = isObject ? this.text : this;
|
|
|
+ if (t === "" || query.matcher(t, text)) {
|
|
|
+ filtered.results.push(isObject ? this : {id: this, text: this});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ query.callback(filtered);
|
|
|
+ }
|
|
|
};
|
|
|
}
|
|
|
|