Select2 selected option disable


#1

There few items in dropdown menu. one item is selected I want to freeze the item.

$('#m_select2_2').change(function () {
 			$.each(this.options, function (i, item) {
 				console.log("checked");
 				if (item.selected) {
 					$(item).prop("disabled", true);
 				} else {
 					$(item).prop("disabled", false);
 				}
 			});
 		});

This one is not working. please help me .


#2

I found the solution.

$("#m_select2_2").select2()
.on("select2:select", function (e) {
    var selected_element = $(e.currentTarget);
    var select_val = selected_element.val();
    $.each(this.options, function (i, item) {
        if (item.selected) {
            $(item).prop("disabled", true); 
        }
    });
    console.log(select_val);
    $('select').select2();
});