I'm using a select2 plugin to get multiple input from user. But I need to prevent the user from removing already selected options, i.e. which is already present in db to be more specific. But the user should be able to select and remove other options as he wish untill is saved to db.
I tried following code.
$('#segment_selected').find(':selected').attr('disabled','disabled');
$("#segment_selected").trigger('change');