Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus cannot be reset using $('#someSelect').chosen().change( ... ) #43

Closed
scaleupcto opened this issue Jul 22, 2011 · 3 comments
Closed

Comments

@scaleupcto
Copy link

The focus cannot be set into input using the chosen().change( .. ) event handler..

<input id='someInput' type='text'/>
<select id='someSelect'>
  <option value='someVal'>Some Value</option>
  <option value='someVal2'>Some Value 2</option>
</select>
    $("#someSelect").chosen().change(function() {
         $("#someInput").first().focus();
     });
@ksevelyar
Copy link

+1

@pfiller
Copy link
Contributor

pfiller commented Dec 6, 2012

I'm not really sure what about Chosen is keeping that focus from firing. I tried moving the trigger("change") call to the end of the select function, but that didn't seem to make a difference with the code you provided.

If you put the focus inside a brief timeout, it works as expected. A little less elegant, but it works. I made a Fiddle that shows it in action, but the gist of it is below.

    $("#someSelect").chosen().change(function(evt){
        setTimeout(function(){
            $("#someInput").focus();
        },50);
    });

@pfiller pfiller closed this as completed Dec 6, 2012
@designosis
Copy link

Thanks for the workaround, which is worth a mention in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants