i have applied select2 on some select box, but i want to open these only on left click, not on right or middle click.
jQuery(".dropdown").select2({placeholder: "some text"});
I tried many things but nothing seems to work. please help.
i have applied select2 on some select box, but i want to open these only on left click, not on right or middle click.
jQuery(".dropdown").select2({placeholder: "some text"});
I tried many things but nothing seems to work. please help.
 
    
    Looking at the following question on stack: How to distinguish between left and right mouse click with jQuery
You could use a switch case to keep the select element closed depending on which mouse button was clicked, example:
$('.select2-selection').mousedown(function(event) {
    switch (event.which) {
        case 1:
            alert('Left Mouse button pressed.');
            break;
        case 2:
            alert('Middle Mouse button pressed.');
            $('select').select2("close"); 
            break;
        case 3:
            alert('Right Mouse button pressed.');
            $('select').select2("close"); 
            break;
        default:
            alert('You have a strange Mouse!');
    }
});
Alternatively you could use the disable/enable options in Select2.