Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger blur on select2

I was wondering if there is a way to trigger blur on a select2 v3.5.2. I know v4.0 is out, however I am not at a position where I can perform an upgrade to the latest version.

On another SO thread, I discovered a (undocumented possibly) way of gaining focus on select2:

$(mySelect).select2('focus');

So I am wondering if there is a way of doing:

$(mySelect).select2('blur');
like image 277
Parth Shah Avatar asked Jan 23 '26 22:01

Parth Shah


1 Answers

You could do it using :

setTimeout(function() {
    $('.select2-container-active').removeClass('select2-container-active');
    $(':focus').blur();
}, 1);

Hope this helps.

like image 167
Zakaria Acharki Avatar answered Jan 26 '26 13:01

Zakaria Acharki