From bdd746844db36c3f78efa8b33dea023b1ecaa0af Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Mon, 17 Sep 2012 19:25:21 -0700 Subject: [PATCH] tweak formatSelection for #400 --- select2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index eee5d8ca..e0e946f1 100644 --- a/select2.js +++ b/select2.js @@ -2059,8 +2059,10 @@ val = this.getVal(), formatted; - formatted=this.opts.formatSelection(data, choice); - choice.find("div").replaceWith("
"+this.opts.escapeMarkup(formatted)+"
"); + formatted=this.opts.formatSelection(data, choice.find("div")); + if (formatted != undefined) { + choice.find("div").replaceWith("
"+this.opts.escapeMarkup(formatted)+"
"); + } choice.find(".select2-search-choice-close") .bind("mousedown", killEvent) .bind("click dblclick", this.bind(function (e) {