Fix initialization of several select2 inputs on the same page (#7182)

This commit is contained in:
Yuriy Bakhtin 2024-08-23 11:47:14 +03:00 committed by GitHub
parent 137446a670
commit 122a26c6d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 11 deletions

View File

@ -20,6 +20,7 @@ HumHub Changelog
- Fix #324: Focus on active and selected nav page after reload on mobile
- Fix #7170: Fix rendering of new line on email messages
- Fix #7178: Highlight only words with 3 or more characters
- Fix #7182: Fix initialization of several select2 inputs on the same page
1.16.1 (July 1, 2024)
---------------------

View File

@ -192,17 +192,19 @@ humhub.module('ui.additions', function (module, require, $) {
: item.text;
};
$match.select2({
theme: 'humhub',
tags: typeof $match.data('ui-select2-allow-new') !== 'undefined',
insertTag: function (data, tag) {
if (typeof $match.data('ui-select2-new-sign') !== 'undefined') {
tag.text += ' ' + $match.data('ui-select2-new-sign');
}
data.unshift(tag);
},
templateResult: templateItem,
templateSelection: templateItem,
$match.each(function () {
$(this).select2({
theme: 'humhub',
tags: typeof $(this).data('ui-select2-allow-new') !== 'undefined',
insertTag: function (data, tag) {
if (typeof $(this).data('ui-select2-new-sign') !== 'undefined') {
tag.text += ' ' + $(this).data('ui-select2-new-sign');
}
data.unshift(tag);
},
templateResult: templateItem,
templateSelection: templateItem,
});
});
});