1
0
mirror of synced 2024-11-21 20:46:07 +03:00

Merge pull request #2 from retailcrm/patch-exclude-create-duplicate-tags

Excludes create options with duplicate tag
This commit is contained in:
IvanLutokhin 2019-11-20 15:00:50 +03:00 committed by GitHub
commit c2b888cd30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
if (tag != null) {
var $option = self.option(tag);
$option.attr('data-select2-tag', true);
// excludes create options with duplicate tag
if (
self.$element.find('option[value = "' + tag.id + '"]').length === 0
) {
var $option = self.option(tag);
$option.attr('data-select2-tag', true);
self.addOptions([$option]);
self.addOptions([$option]);
}
self.insertTag(data, tag);
}

File diff suppressed because one or more lines are too long

11
dist/js/select2.js vendored
View File

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