我正在使用 Twitter Bootstrap 模式窗口功能。当有人在我的表单上单击提交时,我想在单击表单中的“提交按钮”时显示模式窗口。
<form id="myform" class="form-wizard">
<h2 class="form-wizard-heading">BootStap Wizard Form</h2>
<input type="text" value=""/>
<input type="submit"/>
</form>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
jQuery:
$('#myform').on('submit', function(ev) {
$('#my-modal').modal({
show: 'false'
});
var data = $(this).serializeObject();
json_data = JSON.stringify(data);
$("#results").text(json_data);
$(".modal-body").text(json_data);
// $("#results").text(data);
ev.preventDefault();
});
原文由 user244394 发布,翻译遵循 CC BY-SA 4.0 许可协议
Bootstrap 有一些可以在 modals 上手动调用的函数:
你可以在这里看到更多: Bootstrap modal 组件
特别是 方法部分。
所以你需要改变:
至:
如果您想制作自己的自定义弹出窗口,以下是来自其他社区成员的推荐视频:
https://www.youtube.com/watch?v=zK4nXa84Km4