Bootstrap 4表单HTML Popover

时间:2019-07-08 14:59:35

标签: jquery forms bootstrap-4 popover

尝试从Bootstrap 3升级。 以前,我在一些弹出窗口中有一个窗体,现在该窗体已被清空。我无法弄清楚改变这一点的变化。 该表单可以动态演示,但是可以轻松复制。

HTML:

<a id="workingpopovertest" data-toggle="popover">
    <button>Test</button>
</a>
<br /><br /><br /><br />&nbsp;
<a id="brokenpopovertest" data-toggle="popover">
    <button>Test</button>&nbsp;
</a>

脚本:

    $("#brokenpopovertest").popover({
        html: true,
        title: "Broken Popover",
        animation: true,
        content: "<form>Input<input type='text' /></form>",
        container: "body"
    });
    $("#workingpopovertest").popover({
        html: true,
        title: "Working Popover",
        animation: true,
        content: '<h1>I Work Well</h1>',
        container: "body"
    });

给出此结果(如元素命名所预期!!

enter image description here

已添加修改

此与:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>

1 个答案:

答案 0 :(得分:1)

您正在搜索sanitize选项

MORE INFO

$("#brokenpopovertest").popover({
  html: true,
  title: "Broken Popover",
  animation: true,
  sanitize: false,
  content: "<form>Input<input type='text' /></form>",
  container: "body"
});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<a id="brokenpopovertest" data-toggle="popover">
  <button>Test</button>&nbsp;
</a>