Can anyone tell me how I can set the focus on a Select2 when a modal dialog is loaded?
I’ve tried autofocus on the widget itself, it didn’t work.
In the Index page, I tried
$(’#modal’).on(‘shown.bs.modal’, function () {
$(’#select2-projects-clientid-container’).select2(‘open’).select2(‘close’);
})
and
$(‘body’).on(‘shown.bs.modal’, ‘#modal’, function () {
$(’#select2-projects-clientid-container:visible:enabled:first’, this).focus();
})
On the modal page I’ve tried …
I just can’t seem to figure out a way to make it have the focus once the modal has loaded. I don’t need it to drop down or anything, simply have the focus.