浏览代码

tweak formatSelection for #400

Igor Vaynberg 12 年之前
父节点
当前提交
bdd746844d
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      select2.js

+ 4 - 2
select2.js

@@ -2059,8 +2059,10 @@
                 val = this.getVal(),
                 formatted;
 
-            formatted=this.opts.formatSelection(data, choice);
-            choice.find("div").replaceWith("<div>"+this.opts.escapeMarkup(formatted)+"</div>");
+            formatted=this.opts.formatSelection(data, choice.find("div"));
+            if (formatted != undefined) {
+                choice.find("div").replaceWith("<div>"+this.opts.escapeMarkup(formatted)+"</div>");
+            }
             choice.find(".select2-search-choice-close")
                 .bind("mousedown", killEvent)
                 .bind("click dblclick", this.bind(function (e) {