Topic: Multiple Select, Mark selected items on page load
Ronald Patino
free
asked 8 years ago
Hi I am currently integrating MDB with Grails 3
My question is how to mark all the selected items in a multiple select when the page loads.
Of course I already have the selected items which are passed to the page.
Hope you can shed some light.
Thanks
Add comment
Adrian Sawicki
free
answered 8 years ago
Hi,
I have a solution for you. It's quite ugly but it should work for now.
HTML:
<select class="mdb-select" multiple>
<option value="" disabled selected>Choose your option</option>
<option value="1" class="active selected">Option 1</option>
<option value="2" class="active selected">Option 2</option>
<option value="3" class="active selected">Option 3</option>
</select>
<label>Example label</label>
JS:
$(document).ready(function() {
$('.mdb-select').material_select();
var x = $('.dropdown-content').find('li');
for(let i = 1; i <= 4; i++) {
x.eq(i).trigger('click');
}
$('body').trigger('click');
});
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Specification of the issue
- ForumUser: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No