1
0
mirror of synced 2025-02-10 17:19:23 +03:00

Fixed issue with defining the text property as string

because data gets reset afterwards also look at
failing example #e10_2
This commit is contained in:
Johan Buts 2012-06-13 13:09:43 +02:00
parent 94ffecb824
commit cd538772df

View File

@ -267,13 +267,17 @@
* the text. * the text.
*/ */
function local(options) { function local(options) {
var data = options, // data elements var data = options, // data elements,
dataText = '',
text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
if (!$.isArray(data)) { if (!$.isArray(data)) {
text = data.text; text = data.text;
// if text is not a function we assume it to be a key name // if text is not a function we assume it to be a key name
if (!$.isFunction(text)) text = function (item) { return item[data.text]; }; if (!$.isFunction(text)) {
dataText = data.text; // we need to store this in a seperate variable because in the next step data gets reset and data.text is no longer available
text = function (item) { return item[dataText]; };
}
data = data.results; data = data.results;
} }