Skip to content
This repository
Browse code

backport local helper fix. fixes #150

  • Loading branch information...
commit dfee6c2d50956d7769e6a3fc8fe9ac1852b62eb3 1 parent d62bc5b
Igor Vaynberg authored

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +5 1 select2.js
6 select2.js
@@ -267,12 +267,16 @@
267 267 */
268 268 function local(options) {
269 269 var data = options, // data elements
  270 + dataText,
270 271 text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
271 272
272 273 if (!$.isArray(data)) {
273 274 text = data.text;
274 275 // if text is not a function we assume it to be a key name
275   - if (!$.isFunction(text)) text = function (item) { return item[data.text]; };
  276 + if (!$.isFunction(text)) {
  277 + 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
  278 + text = function (item) { return item[dataText]; };
  279 + }
276 280 data = data.results;
277 281 }
278 282

0 comments on commit dfee6c2

Please sign in to comment.
Something went wrong with that request. Please try again.