Вставка кнопок в Popover не работает - PullRequest
0 голосов
/ 07 января 2020

Я пытаюсь вставить 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
Куда делась остальная часть моего контента ???
Я не установил css, например: display: none или .hide () или видимость: hidden или removeClass () или et c на любую кнопку

1 Ответ

0 голосов
/ 08 января 2020

Вы можете сделать это, работая приведенный ниже пример:

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>
...