Topic: Active Class missing from material select form
developers
pro
asked 6 years ago

Rafał Rogulski
free
answered 5 years ago
jkilbride
free
answered 5 years ago
$('.mdb-select').material_select();
However, with single (not multiple) value selects, the initially selected option is not being displayed correctly in the MDB dropdown list. So, I use the code above to add the missing classes to the correct item in the dropdown.
Thanks!
Rafał Rogulski
free
answered 5 years ago
jkilbride
free
answered 5 years ago
selected
value and add the active
and selected
classes to the matching list element when the page loads:
$('select').not('[multiple]').each(function() {
var $this = $(this);
var selectedFilter = ':contains("' + $this.children(':selected').text() + '")';
$this.siblings('ul.select-dropdown').children(selectedFilter).eq(0).addClass('active selected');
});
The multiple value selects seem to work fine. It's only the single value selects I have a problem with.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No