Topic: Multiselect Values? Nice UI, horrible deployment for devs
agrantham free asked 6 years ago
I am a little baffled. I spent the money and purchased the Pro version of this as the components seemed exactly what I need and now that I am implementing some they are more difficult to use than they really should be.
My Issue:
I have a filterable multiselect dropdown. I can select multiple options. It looks great.
How does one get the list of selected items? I have seen some wild examples of traversing through the DOM to find sting matches from the <li> to text inside <options> to get the VALUE of the drop down. Is this really the only way? There should be something closer to:
const vals = $('.mdb-select#myAwesomeDropdown').material_select('get_selected_values');
// Which should return and array of values
console.log(vals);
// ['val1','val2','val3']
This is how I am currently getting a single value dropdown:
$("div.select-wrapper.initialized option:contains("+$(".booklet-reward input").val()+")").val();It is not pretty or intuitive and honestly takes more development time to manipulate this library to make a useful front end. I hope someone has a better solution as that is all I could find through google searches.
Add comment
Mikołaj Smoleński staff answered 6 years ago
Hi agrantham,
Can You try to get values of multiselect usign the below code:
$('.mdb-select').change(function () { var values = $(this).val(); console.log(values); });It is the easiest way to get values storing them in an array. Regards
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Answered
Specification of the issue
- ForumUser: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: Yes
- Provided link: No
Tags