показать/скрыть всплывающее окно работает нормально, но текстовая область и кнопка — нет.< /p>
если я нажму на любой из них, модальное окно сфокусируется на «кнопке удаления», как показано ниже.
Статическое всплывающее окно
HTML
Код: Выделить всё
Код: Выделить всё
Button
Код: Выделить всё
$('[data-field="OnHold"]', row)
.attr('id', x.Id)
.prop('checked', x.OnHold)
.popover({
html: true,
trigger: 'click',
customClass: 'shadow',
placement: 'top',
title: 'On Hold Reason',
sanitize: false,
container: 'body',
//content needs to setTimeout
content: function () {
return $('.popoverContent').clone().show();
}
})
.on('shown.bs.popover', function () {
const popover = $(this).next('.popover'); // Acessa o popover imediatamente após o elemento clicado
// Foca na textarea dentro do popover exibido
popover.find('textarea').trigger('focus');
// Lida com o clique no botão dentro do popover clonado
popover.find('button').on('click', function(e) {
e.stopImmediatePropagation();
const reason = popover.find('textarea').val(); // Pega o valor da textarea dentro do popover
alert('Button clicked with reason: ' + reason);
});
})
.on('change', function (e) {
x.OnHold = $(this).prop('checked');
console.log(`${x.Id}: OnHold changed to ${x.OnHold}`);
$(this).attr('data-content', 'new text').data('bs.popover');
e.stopPropagation();
});
Подробнее здесь: https://stackoverflow.com/questions/790 ... pover-body
Мобильная версия