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) {