0
我试图通过jQuery单击事件启动后设置模式文本,但我没有成功。有人能给我一些指点吗?动态设置Bootstrap Modal文本?
我试着动态地设置标题,正文和按钮,但由于某种原因它没有被添加。
$(function() {
$(".contact-input-plus").on("click", "a", function() {
if (! $(this).is(".remove")) {
// Do stuff
} else {
$('#confirm').modal('show');
$('#confirm').on('show.bs.modal', function() {
var modal = $(this);
modal.find('.modal-body p').text('You are about to remove this entry. Are you sure?');
modal.find('.modal-header h4').html('Remove entry');
modal.find('.modal-footer a.btn').text('Remove');
});
}
return false;
});
});
注:我需要澄清一些东西。该模式首先显示没有文本设置。当我再次取消并激活模式时,将插入文本。
是'$( '#确认')模态( '秀');'正常启用。?是! $(this).is(“。remove”)'评估你打算的方式? – Tim
是的,它正在正常点火。但是文字值并没有被第一次添加到模态中 - 仅仅是从第二次开始... – Taapo
因此,在第一次尝试时打开模式,文本没有被添加,但是在随后的尝试中它是? – Tim