简体   繁体   English

Bootstrap完成功能后,如何在jQuery中运行功能?

[英]How do I run a function in jQuery after Bootstrap completes a function?

I am working on a final project due in less than 24 hours and am working on the final requirement, which is to add custom Javascript to my code that is not complete bootstrap. 我正在完成不到24小时的最终项目,并且正在完成最终要求,这是将自定义Javascript添加到我的代码中,而该代码不是完整的引导程序。

I have a bootstrap created form with a submit button. 我有一个带有提交按钮的引导程序创建的表单。 I used jQuery to trigger a bootstrap modal to appear displaying a success message upon the clicking of that button. 我使用jQuery来触发引导程序模态,以在单击该按钮时显示成功消息。 The modal closes when the user clicks the "x" or clicks outside the modal window. 当用户单击“ x”或在模态窗口外单击时,模态关闭。

Once the modal window closes, I am attempting to hide the form from the page using jquery. 模态窗口关闭后,我试图使用jquery从页面隐藏表单。 Here is my code snippet below: 这是我的以下代码段:

//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();
    });
});

use hidden.bs.modal : 使用hidden.bs.modal

$('#myModal').on('hidden.bs.modal', function(){
    // do your stuff here...
});

hidden.bs.modal occurs when the modal is fully hidden (after CSS transitions have completed) 当模式完全隐藏时(在CSS转换完成后),就会发生hidden.bs.modal

Listen when the modal is closed 模态关闭时收听

$(document).on('hidden.bs.modal', '#myModal', function () {
 $("#formToggle").hide();
});

https://jsfiddle.net/yd9nffxe/6/ https://jsfiddle.net/yd9nffxe/6/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM