Topic: mdb-select not setting ACTIVE class for selected option
szq
pro
asked 6 years ago
- option. So when you click to change the selected option it is not possible to see what was previously selected.
Maybe there is something wrong with my markup but I can't find it.
Or is there something wrong in the mdb-select javascript??
Adrian Sawicki
free
answered 5 years ago
transpera pro commented 4 years ago
This still appears to be the case in the current build. When you init the $('#').material_select() it doesn't automatically set the '.active' class on the current selected item. Functionality isn't affected, but ux is since there's no initial indication on the dropdown of which item is currently selected on init.
harc
pro
answered 5 years ago
// 05.09.2017 - Michael Harclerode (aka Harc)
// mdb.js - original source lines were 10093 - 10107
// Harc modification to below if statement block;
// the original code wasn't allowing including carry of defined css class for an option
// (I also reduce unnecessary waste of outputting "class" strings if there are no classes)
// ---- BEGIN Harc modification section
if (!classes) classes = ''
// Check for multiple type.
if (type === 'multiple') {
if (classes || !!disabledClass) {
options.append($('<li class="' + disabledClass + classes + '"><span><input type="checkbox"' + disabledClass + '/><label></label>' + option.html() + '</span></li>'))
}
else {
options.append($('<li><span><input type="checkbox"' + disabledClass + '/><label></label>' + option.html() + '</span></li>'))
}
}
else {
if (classes || !!disabledClass) {
options.append($('<li class="' + disabledClass + classes + '"><span>' + option.html() + '</span></li>'))
}
else {
options.append($('<li><span>' + option.html() + '</span></li>'))
}
}
// -- END Harc modification for code block
detiege guillaume
free
answered 6 years ago
var activateOption = function (collection, newOption, firstActivation) {
if (newOption) {
collection.find('li.selected').removeClass('selected');
var option = $(newOption);
option.addClass('selected active'); /*Here Add active*/
if (!multiple || !!firstActivation) {
options.scrollTo(option);
}
}
};
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