Permalink
Browse files

backport local helper fix. fixes #150

  • Loading branch information...
1 parent d62bc5b commit dfee6c2d50956d7769e6a3fc8fe9ac1852b62eb3 @ivaynberg ivaynberg committed Jun 22, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 select2.js
View
@@ -267,12 +267,16 @@
*/
function local(options) {
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 separate 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;
}

0 comments on commit dfee6c2

Please sign in to comment.