From cd538772dfc2d99da152f9f171a76ebdc0a42827 Mon Sep 17 00:00:00 2001 From: Johan Buts Date: Wed, 13 Jun 2012 13:09:43 +0200 Subject: [PATCH] Fixed issue with defining the text property as string because data gets reset afterwards also look at failing example #e10_2 --- select2.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index e2a8db5c..829b43ec 100755 --- a/select2.js +++ b/select2.js @@ -267,13 +267,17 @@ * the text. */ 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 if (!$.isArray(data)) { text = data.text; // 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; }