I am using select2 library over a search bar. What happens is when the search results appear in the drop-down as list select2 automatically gives first option as selected, which I don't want.
I want no option to be selected by default instead want to get it selected whenever the user presses and up/down arrow key after the results appear.
Can some-one please help me in achieving this ?
Thanks.
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.
This is not an answer at all and i'm sorry for this false hope but an answer would surely help me too !
--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at https://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.
$('#keywordselect').select2({
placeholder: 'Select...',
closeOnSelect: false,
multiple: true,
});
// one clears the box content and the other clears the highlighting
$('#keywordselect').val(null);
$('.select2-selection__rendered').html('');
add empty option to top of the <select> tag . Do this before intialization
<option></option>
--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/select2/9b8b39fe-71d4-4b89-89ca-0bdb0c120a3an%40googlegroups.com.
Thirty one Products offers a wide range of high-quality items designed to simplify daily life and enhance personal style. From practical essentials to stylish accessories, their products combine functionality with modern design. With Thirty one Products, you can enjoy reliable, well-crafted items that make everyday tasks easier and more enjoyable.