-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 <igor.vaynberg@gmail.com>
This commit is contained in:
parent
5a73385474
commit
1a4b523871
16
select2.js
16
select2.js
@ -1697,18 +1697,20 @@
|
|||||||
// multi
|
// multi
|
||||||
addSelectedChoice: function (data) {
|
addSelectedChoice: function (data) {
|
||||||
var choice,
|
var choice,
|
||||||
id = this.id(data),
|
id = this.id(data),
|
||||||
parts,
|
//span.formatSelection is only temporary
|
||||||
val = this.getVal();
|
|
||||||
|
|
||||||
parts = ["<li class='select2-search-choice'>",
|
parts = ["<li class='select2-search-choice'>",
|
||||||
this.opts.formatSelection(data),
|
"<span class='formatSelection'></span>",
|
||||||
"<a href='javascript:void(0)' class='select2-search-choice-close' tabindex='-1'></a>",
|
"<a href='javascript:void(0)' class='select2-search-choice-close' tabindex='-1'></a>",
|
||||||
"</li>"
|
"</li>"
|
||||||
];
|
],
|
||||||
|
val = this.getVal();
|
||||||
|
|
||||||
choice = $(parts.join(""));
|
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) {
|
.bind("click dblclick", this.bind(function (e) {
|
||||||
if (!this.enabled) return;
|
if (!this.enabled) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user