From 270d4bad072b29f8536afcfb6032d37483e56642 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Wed, 6 Feb 2013 15:26:19 -0800 Subject: [PATCH] default initSelection in tags mode instead of overriding it. fixes #811 --- select2.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/select2.js b/select2.js index 57151ff4..340c5f31 100644 --- a/select2.js +++ b/select2.js @@ -789,17 +789,19 @@ the specific language governing permissions and limitations under the Apache Lic if (opts.createSearchChoice === undefined) { opts.createSearchChoice = function (term) { return {id: term, text: term}; }; } - opts.initSelection = function (element, callback) { - var data = []; - $(splitVal(element.val(), opts.separator)).each(function () { - 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}); - }); + if (opts.initSelection === undefined) { + opts.initSelection = function (element, callback) { + var data = []; + $(splitVal(element.val(), opts.separator)).each(function () { + 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); - }; + callback(data); + }; + } } } }