Hi,
I have this input field that I use with typeahead. It has an autofocus attribute that instructs the browser to focus on it. That worked before adding typeahead. After adding typeahead, that is no longer working.
<input autofocus="autofocus" class="string required span6"
data-behavior="typeahead"
data-typeahead="products" id="payment_detail" name="payment[detail]"
size="50" type="text">
I am also curious how to do this too.
Looking through the source I found the focus method on the InputView but I'm not sure how to call it.
https://github.com/twitter/typeahead.js/blob/master/src/input_view.js#L104
It seems like typeahead.js should respect the autofocus attribute but you can trigger the focus event off the instantiation:
$('#typeahead').typeahead({
name: 'typeahead',
remote: '/typeahead/%QUERY.json',
limit: 10
}).focus();
@bryanluman - thanks for the workaround!
This is still an issue. @jharding, Why was it closed?
@toddmo I don't think this project is maintained anymore, see #1618
Most helpful comment
It seems like typeahead.js should respect the autofocus attribute but you can trigger the focus event off the instantiation: