Dropdown not closing when using custom adapter
See original GitHub issueHey
I created my box with
$('select').select2()
. To style the dropdown, I specified containerCssClass
in the options,
*$('select').select2({
containerCssClass: 'select2-side-services-phone-time'
});
but the dropdown does not receive the class for some reason, also the console shows no error. Next try was to change the dropdown attachment to the container instead of the body which was really a hassle
$.fn.select2.amd.require([
"select2/utils",
"select2/dropdown",
"select2/dropdown/attachContainer"
], function (Utils, DropdownAdapter, AttachContainer) {
$('select').select2({
dropdownAdapter: Utils.Decorate(DropdownAdapter, AttachContainer)
});
});
. The dropdown now is created in place and I can style it accordingly but it does not close anymore. Not with the escape key, not when losing focus, not when chosing an item. Adding the option closeOnSelect: true
did not help as well.
Any idea what I am doing wrong?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Custom Spinner not hiding the dropdown menu after selection
GONE) works to hide the dropdown but it seems to cause issues with the Spinner state, i.e. you will be unable to reopen...
Read more >BaseAdapter with Android ListView - CodePath Cliffnotes
Before we create our custom BaseAdapter implementation, we need to create the layout for the ListView row and also a model for the...
Read more >Customizing Android Popup Spinner (Dropdown List) with ...
PowerSpinner provides another custom adapter called IconSpinnerAdapter . We can implement a list that items have an icon like the below ...
Read more >Using lists in Android wth ListView - Tutorial - Vogella.com
The input of a list (items in the list) can be arbitrary Java objects. The adapter extracts the correct data from the data...
Read more >Android Spinner Disable Item Dropdown Selecetd Item
You need to close or hide the whole dropdown menu when you have only one item in your spinner. Let us achieve this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve managed to make this work using the following code:
@digitalsounds Dude, you are a life saver. I was just struggling with the closeOnSelect being attached to the container. It would work as is but I would lose the search decorator, or vice versa depending on the order I would call them.
Here is my final setup, with your helper code…notice the select initialization is separate for more portability.