简体   繁体   English

引导程序模式关闭事件

[英]Bootstrap modal close event

I have bootstrap modal which looks something like this ; 我有引导模态,看起来像这样; 引导模态

Following is the code for it 以下是它的代码

<!-- Buy Send Offer Success -->
<div class="modal fade custom-modal" id="make-offer-success" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" onclick="javascript:add_request()"><span aria-hidden="true"><i class="fa fa-close"></i></span></button>
            <h4 class="modal-title" id="myModalLabel"><?php echo $data['item']['brand'].' '.$data['item']['model'];?></h4>
        </div>
        <div class="modal-body">
            <div class="send-success"><i class="fa fa-check"></i> Your offer has been successfully sent</div>
        </div>
        <div class="modal-footer">
            <div class="col-md-6 btn-mrgn">
                <input type="hidden" id="item_unique_id" value="<?php echo $data['item']['item_unique_id']; ?>">
                <input type="hidden" id="buyer_id" value="<?php echo $this->session->userdata['id'] ?>">
                <button type="submit" class="btn gray-btn btn-common upercase" onclick="javascript:add_request()">Close</button>
            </div>
        </div>
    </div>
</div>

I am calling a java script function on close button and on "x" button on the modal. 我在关闭按钮和模态上的“ x”按钮上调用了Java脚本函数。 My problem is when user clicks anywhere on the screen Modal disappears, my function is not called and the screen stays faded. 我的问题是,当用户在屏幕上的任何位置单击时,模态消失,我的函数没有被调用,并且屏幕保持褪色。

Can anyone help to fix this problem?. 任何人都可以帮助解决此问题吗? How can i call my javascript function when user clicks anywhere on screen other than modal close buttons. 当用户单击屏幕上除模式关闭按钮以外的任何位置时,如何调用我的javascript函数。

Instead using the hide event handler, which will be called however the modal was closed(assuming you are using modal method to hide the modal) 而是使用hide事件处理程序,该方法将被调用,但是模式已关闭(假设您正在使用模式方法来隐藏模式)

$('#make-offer-success').on('hide.bs.modal', function(){
    //do your stuff
})

Demo: Fiddle 演示: 小提琴

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

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