1
0
mirror of synced 2024-11-22 13:06:08 +03:00

Excludes create options with duplicate tag

This commit is contained in:
Ivan Lutokhin 2019-11-20 14:58:10 +03:00
parent 53db0130d1
commit b889a8d107
5 changed files with 26 additions and 11 deletions

View File

@ -3725,10 +3725,15 @@ S2.define('select2/data/tags',[
var tag = self.createTag(params); var tag = self.createTag(params);
if (tag != null) { if (tag != null) {
// excludes create options with duplicate tag
if (
self.$element.find('option[value = "' + tag.id + '"]').length === 0
) {
var $option = self.option(tag); var $option = self.option(tag);
$option.attr('data-select2-tag', true); $option.attr('data-select2-tag', true);
self.addOptions([$option]); self.addOptions([$option]);
}
self.insertTag(data, tag); self.insertTag(data, tag);
} }

File diff suppressed because one or more lines are too long

5
dist/js/select2.js vendored
View File

@ -3725,10 +3725,15 @@ S2.define('select2/data/tags',[
var tag = self.createTag(params); var tag = self.createTag(params);
if (tag != null) { if (tag != null) {
// excludes create options with duplicate tag
if (
self.$element.find('option[value = "' + tag.id + '"]').length === 0
) {
var $option = self.option(tag); var $option = self.option(tag);
$option.attr('data-select2-tag', true); $option.attr('data-select2-tag', true);
self.addOptions([$option]); self.addOptions([$option]);
}
self.insertTag(data, tag); self.insertTag(data, tag);
} }

File diff suppressed because one or more lines are too long

View File

@ -79,10 +79,15 @@ define([
var tag = self.createTag(params); var tag = self.createTag(params);
if (tag != null) { if (tag != null) {
// excludes create options with duplicate tag
if (
self.$element.find('option[value = "' + tag.id + '"]').length === 0
) {
var $option = self.option(tag); var $option = self.option(tag);
$option.attr('data-select2-tag', true); $option.attr('data-select2-tag', true);
self.addOptions([$option]); self.addOptions([$option]);
}
self.insertTag(data, tag); self.insertTag(data, tag);
} }