Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open the drop down list permanently of select2

Tags:

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.

like image 589
rkj Avatar asked Jun 14 '13 11:06

rkj


People also ask

How do I stop Select2 from auto selecting the first option?

This behaviour exists not because Select2 is forcing it, but because the browser is auto-selecting the first option for you. We can't control that, we can only work around it. Your best option is to use the placeholder support in Select2 and include a blank option tag as your default selection.

How do I create a dropdown Select 2?

Creating new options in the dropdown New options can be added to a Select2 control programmatically by creating a new Javascript Option object and appending it to the control: var data = { id: 1, text: 'Barn owl' }; var newOption = new Option(data. text, data.id, false, false); $('#mySelect2'). append(newOption).

What Select2 dropdown?

By default, Select2 will attach the dropdown to the end of the body and will absolutely position it to appear above or below the selection container. Select2 will display the dropdown above the container if there is not enough space below the container, but there is enough space above it.


1 Answers

From the select2 documentation, here:

    $("#select").select2({
            closeOnSelect: false
    });
like image 112
Terence Avatar answered Oct 13 '22 01:10

Terence