MDB Multiple Select Default Value - Material Design For Bootstrap

Hi,

I encounter an issue while trying to determine default value for my multiple mdb-select and while the values are numbers.The multiple mdb-select works fine when it's string values.

This is my select :

<select id="product" name="product[]" class="mdb-select md-form initialized" multiple="" searchable="Search"> <option value="">None</option> <optgroup label="Products Cat 1"> <option value="22">Product 1</option> <option value="23">Product 2</option> <option value="24">Product 3</option> <option value="25">Product 4</option> </optgroup> <optgroup label="Products Cat 2"> <option value="1">Product 5</option> <option value="2">Product 6</option> <option value="3" selected>Product 7</option> <option value="4">Product 8</option> </optgroup> </select>

Of course, I initialized the select :

$('.mdb-select').material_select();

My problem is : the mdb select displayed don't have the product with value "3" checked (Product 7 in my case), it has the product with value "22" checked instead (Product 1)...

I tried to destroy et initialize again the select but it did nothing.I also tried to display the value of my select in console and I have this result :["", "22", "3"] instead of ["3"].

I don't want the "22" value, I never checked it ! The value "3" isn't checked in my select neither...

Thank you.

EDIT : Snippet if needed : https://mdbootstrap.com/snippets/jquery/o1ivier/433268

Piotr Glejzer staff commented 6 years ago

Yea, I see the problem. Sorry about that bug. I added a task for that to check/repair it as soon as possible.

Yea, I see the problem. Sorry about that bug. I added a task for that to check/repair it as soon as possible.

Please insert min. 15 characters. Publish

O1ivier priority commented 6 years ago

Hello,

Do you know approximately when will this problem be solved ?

Thanks

Hello,

Do you know approximately when will this problem be solved ?

Thanks

Please insert min. 15 characters. Publish

Piotr Glejzer staff commented 6 years ago

I'm already looking into this. I will try to fix this a soon as possible but It will be probably fixed in the next release.

I'm already looking into this. I will try to fix this a soon as possible but It will be probably fixed in the next release.

Please insert min. 15 characters. Publish Add comment

Từ khóa » Html Select Set Default Value Jquery