javascriptjquerydrop-down-menujquery-chosen

jquery chosen multiple : how to keep menu open between selection


I am using Chosen to give my <select> a proper look and a search input.

The problem is that with a <select multiple> when the user open the dropdown menu to choose the options he wants I want to keep the dropdown open between the clicks. It is really annoying to have the re-open the menu between each option selection.

I searched through the Chosen documentation and through the internet but I couldn't find to do it with Chosen.

Here is how I wrote my <select> and how applied Chosen to it (nothing special) :

<select multiple="multiple" id="foo" class="chosenSelect">
    <option value="NULL" disabled>Chose multiple somthing</option>';
    <option value="bar1">foobar1</option>';
    <option value="bar2">foobar2</option>';
    <option value="bar3">foobar3</option>';
</select>

and

$('.chosenSelect').chosen();

Any help is welcomed.


Solution

  • I am not familiar with the Chosen library; so if there exists a better solution in the library itself, I'd defer to that solution.

    However, if you do not find a better solution, and you still need the functionality, you can use this little hack.

    $('.chosen-results').bind('click', function(e) {
      setTimeout(function() {
        $(e.currentTarget).parent().siblings('.chosen-choices').click()
      });
    });
    

    I reiterate, this is a hack and you should only use this if you've found nothing else. I'll edit the answer if I find something better.