Skip to content

Commit 270d4ba

Browse files
committed
default initSelection in tags mode instead of overriding it. fixes select2#811
1 parent d1e9531 commit 270d4ba

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

select2.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -789,17 +789,19 @@ the specific language governing permissions and limitations under the Apache Lic
789789
if (opts.createSearchChoice === undefined) {
790790
opts.createSearchChoice = function (term) { return {id: term, text: term}; };
791791
}
792-
opts.initSelection = function (element, callback) {
793-
var data = [];
794-
$(splitVal(element.val(), opts.separator)).each(function () {
795-
var id = this, text = this, tags=opts.tags;
796-
if ($.isFunction(tags)) tags=tags();
797-
$(tags).each(function() { if (equal(this.id, id)) { text = this.text; return false; } });
798-
data.push({id: id, text: text});
799-
});
800-
801-
callback(data);
802-
};
792+
if (opts.initSelection === undefined) {
793+
opts.initSelection = function (element, callback) {
794+
var data = [];
795+
$(splitVal(element.val(), opts.separator)).each(function () {
796+
var id = this, text = this, tags=opts.tags;
797+
if ($.isFunction(tags)) tags=tags();
798+
$(tags).each(function() { if (equal(this.id, id)) { text = this.text; return false; } });
799+
data.push({id: id, text: text});
800+
});
801+
802+
callback(data);
803+
};
804+
}
803805
}
804806
}
805807
}

0 commit comments

Comments
 (0)