bootstrap 彈出框點擊其他區域時彈出框不消失選項設置


默認情況下,bootstrap 彈出框點擊其他區域時,彈出框會自動關閉,在很多時候,我們可能會希望達到和原生彈出框一樣的效果,避免不小心點擊其他區域時彈框自動隱藏,尤其是對於一些復雜的表單,重復填寫可能會帶來很不好的體驗效果,所以,我們會希望不會發生這種情況,事實上bootstrap dialog提供了大量的選項可以設置各種dialog的行為和效果。如下所示:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">新增</h4>
</div>
<div class="modal-body">
            </div>
<div class="modal-footer">
<button type="button" id="btn_submit" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>關閉</button>
</div>
</div>
</div>
</div>
$("#add").click(function () {
$("#myModalLabel").text("新增");
$('#myModal').modal({backdrop:"static"}); --設置為static后可以防止不小心點擊其他區域是彈出框消失
});
其他更多選項可見http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM