question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

input autofocus attribute is not working

See original GitHub issue

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">

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
bryanlumancommented, Oct 25, 2013

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();
0reactions
fletchownscommented, Mar 24, 2017

@toddmo I don’t think this project is maintained anymore, see #1618

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto focus is not working for input field - Stack Overflow
Autofocus attribute moves the focus to the specified input on page load. In this case #input is present in DOM but hidden; on...
Read more >
Fixing the auto-focus - HTML Form Guide
Correcting the auto-focus​​ One way to avoid the troubles with the wrong auto-focus is to avoid auto focus if the user has already...
Read more >
Autofocus attribute doesn't work reliably · Issue #186 · elm/html
autofocus is defined to work reliably only on page load. It is not really suited for situations where you are swapping, or opening,...
Read more >
autofocus - HTML: HyperText Markup Language | MDN
The autofocus global attribute is a Boolean attribute indicating that an element should be focused on page load, or when the <dialog> that...
Read more >
HTML input autofocus Attribute - W3Schools
The autofocus attribute is a boolean attribute. When present, it specifies that an <input> element should automatically get focus when the page loads....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found