Friday, 15 April 2016

Remove a drop down item if it is selected ?

   
Remove a drop down item if it is selected  Select2.js?
Ability to hide currently selected value in dropdown ?
Ability to hide currently selected value in dropdown Select2.js ?

$('#ddlType').select2({  
     tags:false,  
     multiple:multiple  
  });  




Hide Selected Tag Css
.select2-results__option[aria-selected="true"] {
  display:none;
}
.select2-results__option[aria-selected="false"] {
  display:block;
}




Prevent select2 dropdown open when clearing selection ?

  var ddl = selectEl.select2({  
       allowClear: true,  
       placeholder: "Select a "+columnName  
    }).on("select2:close",function() {  
      console.log("close");  
    }).on('select2:unselecting', function() {  
       $(this).data('unselecting',true);  
    }).on('select2:opening', function(e) {  
      if ($(this).data('unselecting')) {  
        $(this).removeData('unselecting');  
        e.preventDefault();  
      }  
    }).on("change", function (e) {  
       console.log("change event Call");
    });