Select 2 with bootstrap popover

天大地大妈咪最大 提交于 2021-02-11 15:20:54

问题


I try to set a bootstrap 3.5 popover on select2 4.0.1, but it seems it does not working:

<input id="sampleInput" type="text" rel="popover" data-content="This is the body of Popover" data-original-title="Creativity Tuts" data-placement="auto" data-trigger="hover" />
<p/>
<select id="selectb" data-content="This is the body of Popover" data-original-title="Creativity Tuts" data-placement="auto" data-trigger="hover" data-container="body">
    <option>Please select ...</option>
    <option value="1">Select2</option>
    <option value="2">Chosen</option>
    <option value="4">selectize.js</option>
    <option value="6">typeahead.js</option>
</select>

the js:

$(function () {
    $('#sampleInput').popover();
    $('#selectb').popover();
    $('#selectb').select2();
});

A sample can be found at http://jsfiddle.net/s4w1z09v/

Any comment ?!


回答1:


As a workaround; you could try:

<input id="sampleInput" type="text" rel="popover" data-content="This is the body of Popover" data-original-title="Creativity Tuts" data-placement="auto" data-trigger="hover" />
<p/>
<span id="selectb-popover"
      data-content="This is the body of Popover"
      data-original-title="Creativity Tuts"
      data-placement="auto"
      data-trigger="hover"
      data-container="body">
    <select id="selectb">
        <option>Please select ...</option>
        <option value="1">Select2</option>
        <option value="2">Chosen</option>
        <option value="4">selectize.js</option>
        <option value="6">typeahead.js</option>
    </select>
</span>

and update your js to:

$(function () {
    $('#sampleInput').popover();
    $('#selectb').select2();
    $('#selectb-popover').popover();
});


来源:https://stackoverflow.com/questions/33772705/select-2-with-bootstrap-popover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!