我正在研究最终项目,不到24小时就到了,我正在制定最终要求,即将自定义Javascript添加到我的代码中,而不是完整的引导程序。
我有一个带有提交按钮的bootstrap创建表单。我使用jQuery触发一个bootstrap模式,在单击该按钮时显示成功消息。当用户点击" x"时,模态将关闭。或点击模态窗口外。
一旦模态窗口关闭,我试图使用jquery从页面隐藏表单。以下是我的代码段:
//the modal submit button click event
$('#myModal').modal(show);
//the form dissapears after the modal is closed. #formToggle is the id applid to the <form>
$(document).ready( function() {
$('#formToggle').on('show', function(){
$('#formToggle').remove();
});
});
答案 0 :(得分:1)
使用hidden.bs.modal
:
$('#myModal').on('hidden.bs.modal', function(){
// do your stuff here...
});
当完全隐藏模态时(CSS转换完成后)发生hidden.bs.modal
答案 1 :(得分:1)
关闭模态时收听
$(document).on('hidden.bs.modal', '#myModal', function () {
$("#formToggle").hide();
});