Home > Blockchain >  Bootstrap selectpicker with optgroups displaying duplicate options
Bootstrap selectpicker with optgroups displaying duplicate options

Time:06-08

I am trying to build a selectpicker using Bootstrap 5 with optgroups. My issue is that under each optgroups, all option elements are identical and do not match the HTML I have written in my file. The issue is apparent even when we have something very simple and boiled down, such as this:

<select  multiple id="simple">
   <optgroup label="Fruits">
      <option>Cherry</option>
      <option>Papaya</option>
   </optgroup>
   <optgroup label="Vegetables">
      <option>Lettuce</option>
      <option>Tomato</option>
   </optgroup>
</select>

What this displays is a selectpicker with two optgroups, Fruits and Vegetables, but where both optgroups have the "Cherry" and "Papaya" options. It seems to be using the options from the first optgroup and pulling these into any subsequent optgroups within the select element. Any help with resolving this would be greatly appreciated.

CodePudding user response:

That is exactly the same problem i am facing right now. I am using Bootstrap 4. If i find a solution i will post it here.

edit: Ok i fixed it for me. I switched the bootstrap-select version and now it is working. Now i am using bootstrap-select.1.14.0-beta3.

  • Related