bootstrap
bootstrap copied to clipboard
Bootstrap doesn't allow more than one instance per element. Bound instance: bs.dropdown
Prerequisites
- [X] I have searched for duplicate or closed issues
- [X] I have validated any HTML to avoid common problems
- [X] I have read the contributing guidelines
Describe the issue
i want show tooltip on dropdown toggle button
i thinks it's bug, why i can't use two different component for one element ?
Reduced test cases
https://codepen.io/Davood-Jafari/pen/yLGXWXX
const el = document.querySelector('#myBtn');
new Dropdown(el);
new Tooltip(el);
<div class="dropdown">
<button
id="myBtn"
class="btn btn-secondary dropdown-toggle"
data-bs-title="Default tooltip"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="#"> Action </a>
</li>
<li>
<a class="dropdown-item" href="#"> Another action </a>
</li>
<li>
<a class="dropdown-item" href="#"> Something else here </a>
</li>
</ul>
</div>
What operating system(s) are you seeing the problem on?
macOS
What browser(s) are you seeing the problem on?
Chrome
What version of Bootstrap are you using?
5.2.3
Hello @DJafari. Bug reports must include a live demo of the issue. Per our contributing guidelines, please create a reduced test case on CodePen or StackBlitz and report back with your link, Bootstrap version, and specific browser and Operating System details.
Live Demo : https://codepen.io/Davood-Jafari/pen/yLGXWXX
What operating system(s) are you seeing the problem on? macOS
What browser(s) are you seeing the problem on? Chrome
What version of Bootstrap are you using? 5.2.3
是的,为什么不能在同一个元素上绑定多个组件?
data.js:26 Bootstrap doesn't allow more than one instance per element. Bound instance: bs.tooltip.
I tracked this down to an earlier issue and a prior conversation. This seems intended to maintain (then existing) behavior where only one key could be assigned to an element. The error message seems to be more like a warning that was added as part of a guard clause for the new data structure. I'm not a javascript developer by any means but my understanding is that the error is more like a warning that can be mostly ignored.