Bootstrap 4-将按钮插入Popover无效

问题描述 投票:0回答:1

我正在尝试将2个按钮插入由.clear-history按钮触发的弹出窗口:

<div class="modal-footer text-nowrap">
    <button type="button" class="clear-history btn btn-link">Clear history</button>
</div>

const clearHistoryBtn = `
    <span>All records will be removed</span>
    <button type="button" class="confirm-clear-history btn btn-sm btn-danger">Yes</button>
    <button type="button" class="btn btn-sm btn-link">No</button>
`;
$('.clear-history').popover({
    placement: 'bottom',
    html: true,
    title: 'You are cleaning the history',
    content: clearHistoryBtn
});

但是在弹出框内只有文本:

enter image description here我想知道它是否与模式有关


更新:

enter image description here我内容的其余部分去哪儿了???我没有将任何display,none,.hide()或可见性:hidden或removeClass()等CSS设置为任何按钮

我正在尝试将2个按钮插入弹出式窗口,该按钮由.clear-history按钮触发:

您可以通过这种方式进行操作,下面给出的工作示例:

const clearHistoryBtn = `
    <span>All records will be removed</span>
    <button type="button" class="confirm-clear-history btn btn-sm btn-danger" onclick="alert('event raised from yes button');">Yes</button>
    <button type="button" class="btn btn-sm btn-link" onclick="alert('event raised from no button');">No</button>
`;

$('.clear-history').popover({
    placement: 'bottom',
    html: true,
    title: 'You are cleaning the history',
    content: clearHistoryBtn
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div class="modal-footer text-nowrap">
    <button type="button" class="clear-history btn btn-link">Clear history</button>
</div>
javascript jquery twitter-bootstrap bootstrap-4 bootstrap-modal
1个回答
0
投票

您可以通过这种方式进行操作,下面给出的工作示例:

© www.soinside.com 2019 - 2024. All rights reserved.