I am using the Selectize.js. From the docs it says I can set up a 'onDropdownClose' callback here: Selectize docs. I can't seem to get it to work.
How do I blur (defocus) the input after a selection has been made using Selectize.js? All the blurs in the below code do not work.
$(document).ready(function() {
$("#myinput").selectize({
onDropdownClose : function ($dropdown) {
$($dropdown).prev().find('input').blur();
}
});
});
EDIT: I am using Bootstrap 3.1.1. I just noticed that the default behavior for Bootstrap 2 is to blur the input after a selection has been made while Bootstrap 3+ leaves the input in focus after a selection has been made. My question still stands for Bootstrap 3+
Edit: I got it to work with the above code.
Adding this just to have an actual answer. Your solution works.
$("#myinput").selectize({
onDropdownClose: function(dropdown) {
$(dropdown).prev().find('input').blur();
});
});
I had a similar issue and solved it using:
$('#myinput').selectize({
onItemAdd: function () {
this.blur();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With