nikoka nikoka - 2 years ago 85
Javascript Question

Prevent Select2 from toggling selected items when clicking them in the dropdown

When using Select2 ( for multi-value select boxes you can toggle a selected value from the dropdown. Is there any way to prevent this behaviour? So that you could only remove selected items by clicking on the X next to them.

All help greatly appreciated.

Answer Source

you can use unselecting event:

  .on("select2:unselecting", function (e) { 
    // make sure we are on the list and not within input box
    if (e.params.args.originalEvent.currentTarget.nodeName === 'LI') {


see for more details,

if you want to close select, use $example.select2("close"); (

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download