portal.mkgtu.ru/clientSide/packs/js/select2-educations.js

18 lines
487 B
JavaScript
Raw Permalink Normal View History

2024-03-28 09:51:45 +03:00
const { isEmpty } = require("lodash");
$('.select2-educations').on('select2:select', function (e) {
const data = e.params.data;
if (isEmpty(data) || data.id != data.text) { return; }
const index = $(this)?.val().indexOf(data.id);
if (index < 0) { return; }
let selectedList = [];
$(this)?.val().map(function (value) {
if (value != data.id) {
selectedList.push(value);
}
});
$(this)?.val(selectedList).trigger('change');
});