Skip to content

Commit f06aae3

Browse files
committed
better handling of tags that are not just strings. fixes select2#256
1 parent 1165289 commit f06aae3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

select2.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,10 @@
672672
opts.initSelection = function (element, callback) {
673673
var data = [];
674674
$(splitVal(element.val(), opts.separator)).each(function () {
675-
data.push({id: this, text: this});
675+
var id = this, text = this, tags=opts.tags;
676+
if ($.isFunction(tags)) tags=tags();
677+
$(tags).each(function() { if (equal(this.id, id)) { text = this.text; return false; } });
678+
data.push({id: id, text: text});
676679
});
677680

678681
callback(data);

0 commit comments

Comments
 (0)