Topic: Unselect mdb-select control using Javascript / Jquery
KenHartwigsen free asked 6 years ago
MDBootstrap staff answered 5 years ago
Hi Eeesbk,
To restart our material select you can use attribute destroy: true,
like this:
$('.mdb-select').materialSelect({
destroy: true
});
$('.mdb-select').materialSelect();
This way whole select will be initialized again and all changes that user caused will be reverted.
Best Regards, Piotr
Eeesbk free answered 5 years ago
Hello. Im clear select value $(".active").removeClass();
and submit form... select not clear!! help pls
Jakub Strebeyko staff answered 6 years ago
.material_select()
function hides the select
html element from sight, and what you're clicking on (the options) are span
elements, children to li
s within a newly-created, js-initiated ul
element. And so, what selecting is in that context is granting these parent li
elements the .active
and .selected
classes. The easiest way to unselect in that sense (aka not getting them selected) would be to create a function removing the classes right when they're added, like so:
var select = $('.mdb-select');
select.material_select();
select.on("change", function(){
$(".active").removeClass();
});
Please let us know whether I read you correctly.
With Best Regards,
Kuba
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No