It was harder than I thought, but here is what I came up with:
$('select.multiselect').on('change', function(e) {
var vals = $(this).select2("val");
var selects = $('select').not('#'+$(this).attr('id'));
for (var i = 0; i < selects.length; i++) {
$(selects[i]).find('option').removeAttr('disabled');
for (var j = 0; j < vals.length; j++) {
$(selects[i]).find('option[value='+vals[j]+']').attr('disabled', 'disabled');
}
}
});
Here is the fiddle if you want to see the result in action
Make sure all your items selectare unique id.
Skwal source
share