shown.bs.modal fires multiple times when you close and reopen modal

后端 未结 7 542
囚心锁ツ
囚心锁ツ 2020-12-29 08:07

I have made a fiddle illustrating the issue I am facing at the moment. So every time I close and open a modal, shown.bs.modal also fires multiple times. In this

7条回答
  •  渐次进展
    2020-12-29 08:37

    Define variable and set it's value to 1; like:

    function openTestModal(){
                    $('#testModal').modal({
                        keyboard: false,
                        backdrop: 'static'
                    });
                   var e=1;
                    $('#testModal').on('shown.bs.modal', function (e) {
                        alert('');
                        e=0;
                    });
                }
    

提交回复
热议问题