mikemaccana mikemaccana - 8 months ago 70
Javascript Question

How can I focus on a selectize select box?

Focusing on a select box (that has selectize enabled) does not focus on the selectized input box:

$('.someclass select').focus();

Focusing on selectize's own inout box doesn't seem to work either:

$('.someclass input').focus();

The Selectize docs mentions
but that doesn't seem to work either. See this jsfiddle:

var selectized = $('#selectize').selectize();

I would expect the carat
to be ready and typing to immediately go into the box.

How can I focus on a selectize select box from JavaScript, so a user can type into it?


One way which appears to work is to call click() instead of focus():

$('.someclass input').click();