From 2eb28a60aa3cc687b1aa37cc94e92df70739e914 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Thu, 15 Nov 2012 09:56:05 -0800 Subject: [PATCH] allow override of createSearchChoice in tags. fixes #567 --- select2.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/select2.js b/select2.js index 108a2893..ca355440 100644 --- a/select2.js +++ b/select2.js @@ -797,7 +797,9 @@ the specific language governing permissions and limitations under the Apache Lic opts.query = local(opts.data); } else if ("tags" in opts) { opts.query = tags(opts.tags); - opts.createSearchChoice = function (term) { return {id: term, text: term}; }; + 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 () { @@ -2084,14 +2086,14 @@ the specific language governing permissions and limitations under the Apache Lic " " + ""), disabledItem = $( - "
  • " + + "
  • " + "
    " + "
  • "); var choice = enableChoice ? enabledItem : disabledItem, id = this.id(data), val = this.getVal(), formatted; - + formatted=this.opts.formatSelection(data, choice.find("div")); if (formatted != undefined) { choice.find("div").replaceWith("
    "+this.opts.escapeMarkup(formatted)+"
    ");