From f06aae38fbcd9c8c293764c6934f034b2b29bd3f Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 24 Jul 2012 15:10:31 +0300 Subject: [PATCH] better handling of tags that are not just strings. fixes #256 --- select2.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index ee625807..aa0f20a6 100755 --- a/select2.js +++ b/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);