From 19810405ce7eaee10a765d494bc0d93e5cffac31 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 10 Apr 2012 07:31:59 -0700 Subject: [PATCH] automatically initialize selection in tagging mode. closes #19 --- select2.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/select2.js b/select2.js index b96a4c7e..f152b2a4 100755 --- a/select2.js +++ b/select2.js @@ -437,6 +437,14 @@ } else if ("tags" in opts) { opts.query = tags(opts.tags); opts.createSearchChoice = function (term) { return {id: term, text: term};} + opts.initSelection = function (element) { + var data = []; + $(element.val().split(",")).each(function () { + data.push({id: this, text: this}); + }); + return data; + } + } } }