I read always trigger "change"-event for <select>, even if the select2-option clicked is already selected and as the problem was so close to my issue I asked my question there but no answer provided. My problem is that I have a select-box constructed by Select2 and a text input. What I want to achieve is after Select2 closed (no matter the value is changed or not) my text input become focus.
So I did something logically fine as follow:
$('#select').select2({placeholder: 'City'});
$('#select')
.on('select2-close', function (e) {
$('#hey').focus();
});
http://jsfiddle.net/sobhanattar/x49F2/8/
As you can see, the text input doesn't accept focus. After some digging in Select2 document and inspecting Events part of documentation, I realized that after Close event, there is a Focus event fire automatically. It means that after you close a Select2 select-Box, it focuses itself. So I changed my code to something like this:
$('#select').select2({placeholder: 'City'});
$('#select')
.on('select2-close', function (e) {
$('#select').blur();
})
.on('select2-blur', function(e) {
$('#hey').focus();
});
And it works just fine. Now I want to know that my understanding from Select2 order of events was correct or I missed something in the middle.