admin管理员组文章数量:1387313
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-mon 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. 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.
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-mon 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. 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.
Share Improve this question asked Jul 7, 2015 at 11:51 Mudassar KhaniMudassar Khani 1,4792 gold badges22 silver badges39 bronze badges1 Answer
Reset to default 4Instead using the hide event handler, which will be called however the modal was closed(assuming you are using modal method to hide the modal)
$('#make-offer-success').on('hide.bs.modal', function(){
//do your stuff
})
Demo: Fiddle
本文标签: javascriptBootstrap modal close eventStack Overflow
版权声明:本文标题:javascript - Bootstrap modal close event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744483186a2608291.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论