Open the drop down list permanently of select2
Asked Answered
B

2

21

I'm using select2 for multiple value selection. I need to display the drop down list permanently.

Right now when we select or click the input box of select2, the drop down list is displayed. I'd like to know if there is any way we can always show the list.

Bedeck answered 14/6, 2013 at 11:57 Comment(0)
A
32

From the select2 documentation, here:

    $("#select").select2({
            closeOnSelect: false
    });
Anarthrous answered 14/6, 2013 at 12:33 Comment(2)
Thank You @Terence, though if i unfocus from the input box of select2 it would be hidden. I need to keep the drop down menu always open. I'm trying manually by checking the classes on opening and closing of select2 and would write some jquery on change function there.Bedeck
closeOnselect works if your select is in multiselect mode..see the documentationNightcap
P
5

Try this:

var list = $("#select").select2({
    closeOnSelect: false
}).on("select2:closing", function(e) {
    e.preventDefault();
}).on("select2:closed", function(e) {
    list.select2("open");
});

For Ref Click here

Pemberton answered 30/1, 2020 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.