带有OptGroup的Bootstrap SelectPicker显示重复选项

发布于 2025-01-29 12:32:26 字数 653 浏览 4 评论 0原文

我正在尝试使用带有OptGroup的Bootstrap 5构建SelectPicker。我的问题是,在每个OptGroup下,所有选项元素都是相同的,并且与我在文件中写的HTML不匹配。即使我们拥有非常简单和沸腾的东西,例如:

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

显示的内容是一个带有两个Optgroup,水果和蔬菜的选择,但是两个Optgroup都具有“樱桃”和“ Papaya”选项。它似乎正在使用第一个OptGroup中的选项,并将其拉到Select元素中的任何后续optgroup中。解决此问题的任何帮助将不胜感激。

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 class="form select selectpicker" 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偷得浮生 2025-02-05 12:32:26

这是我现在面临的完全相同的问题。我正在使用Bootstrap 4。如果找到解决方案,我将在此处发布。

编辑:
好吧,我为我修理了它。
我切换了Bootstrap-select版本,现在正在工作。
现在我正在使用bootstrap-select.1.14.0-beta3。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文