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

Open dropdown when tabbed onto field #1947

Closed
SFPink opened this issue May 23, 2014 · 4 comments
Closed

Open dropdown when tabbed onto field #1947

SFPink opened this issue May 23, 2014 · 4 comments

Comments

@SFPink
Copy link

SFPink commented May 23, 2014

Hello,

Is there a way of opening the drop down when the user tabs onto the chosen select?
I haven't seen anything in the docs regarding this but then again I could have missed it.

Found this after a quick search:

$('body').on('focus', '.chosen-container-single input', function(){
    if (!$(this).closest('.chosen-container').hasClass('chosen-container-active')){
        $(this).closest('.chosen-container').trigger('mousedown');
        //or use this instead
        //$('#select').trigger('liszt:open');
    }    
});

Will give this ago. I don't suppose there is an option built in though?

Thanks

@koenpunt
Copy link
Collaborator

Chosen triggers a focus events, so the following should work:

$('body').on('focus', '.chosen-select', function(event){
  $(this).trigger('chosen:open');
});

The events in your found code are old and no longer supported.

@koenpunt
Copy link
Collaborator

My bad, the focus event is not triggered on the select itself.

@koenpunt koenpunt reopened this May 24, 2014
@SFPink
Copy link
Author

SFPink commented Jun 11, 2014

Temporary Solution:

jQuery('body').on('focus', '.chosen-container-single input', function () {
    if (!jQuery(this).closest('.chosen-container').hasClass('chosen-container-active')) {
        jQuery(this).closest('.chosen-container').prev().trigger('chosen:open');
    }
});

@pfiller
Copy link
Contributor

pfiller commented Jun 4, 2016

@SFPink's temporary solution looks like a good workaround. I'm closing this up!

@pfiller pfiller closed this as completed Jun 4, 2016
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

3 participants