Sfoglia il codice sorgente

better handling of tags that are not just strings. fixes #256

Igor Vaynberg 13 anni fa
parent
commit
f06aae38fb
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      select2.js

+ 4 - 1
select2.js

@@ -672,7 +672,10 @@
                         opts.initSelection = function (element, callback) {
                             var data = [];
                             $(splitVal(element.val(), opts.separator)).each(function () {
-                                data.push({id: this, text: this});
+                                var id = this, text = this, tags=opts.tags;
+                                if ($.isFunction(tags)) tags=tags();
+                                $(tags).each(function() { if (equal(this.id, id)) { text = this.text; return false; } });
+                                data.push({id: id, text: text});
                             });
 
                             callback(data);