JQuery Select2 - How to select all options -


i'm using jquery select2 multi select dropdown. need select options in dropdown code. there select checkbox on functionality has implemented, want select/deselect options checkbox.

there description in thread on github. quoting (https://github.com/ivaynberg/select2/issues/195#issuecomment-13489140 mortadaak) allows select on ctrl+a

$(document).on("keypress",".select2-input",function(event){     if (event.ctrlkey || event.metakey) {         var id =$(this).parents("div[class*='select2-container']").attr("id").replace("s2id_","");         var element =$("#"+id);         if (event.which == 97){             var selected = [];             element.find("option").each(function(i,e){                 selected[selected.length]=$(e).attr("value");             });             element.select2("val", selected);         } else if (event.which == 100){             element.select2("val", "");         }     } }); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -