From 1a4b52387172595ae51f239fb24853513f1261e9 Mon Sep 17 00:00:00 2001 From: Mitko Tschimev Date: Thu, 5 Jul 2012 10:58:25 +0200 Subject: [PATCH] -add possibility to return a jQuery object with formatSelection -the close event of the selection is now delegated to the class 'select2-search-choice-close' and not only the a tag Signed-off-by: Igor Vaynberg --- select2.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/select2.js b/select2.js index 00090969..a078b9ff 100755 --- a/select2.js +++ b/select2.js @@ -1697,18 +1697,20 @@ // multi addSelectedChoice: function (data) { var choice, - id = this.id(data), - parts, - val = this.getVal(); - + id = this.id(data), + //span.formatSelection is only temporary parts = ["
  • ", - this.opts.formatSelection(data), + "", "", "
  • " - ]; + ], + val = this.getVal(); choice = $(parts.join("")); - choice.find("a") + // replace span.formatSelection with the returned value of this.opts.formatSelection(data) + // allows the possibility to return jQuery objects with formatSelection + choice.find('.formatSelection').replaceWith(this.opts.formatSelection(data)); + choice.find(".select2-search-choice-close") .bind("click dblclick", this.bind(function (e) { if (!this.enabled) return;