当关闭引导模型区域外的模态时,火灾事件处理程序

时间:2022-05-06 11:32:00

I use bootstrap and angularjs in my project. I use Bootstrap 'Modals'. I'm trying to customize some of the default features.

我在我的项目中使用bootstrap和angularjs。我使用引导“情态动词”。我正在尝试自定义一些默认特性。

How do I fire event handler in controller when I close the modal window by clicking on the background not the close button.

当我通过点击背景而不是关闭按钮关闭模式窗口时,如何在控制器中触发事件处理程序。

1 个解决方案

#1


2  

The hidden.bs.modal event fires whenever the modal is closed, no matter how you close it. See the docs.

hidden.bs。模态事件在模式关闭时触发,不管你如何关闭它。看文档。

EDIT

编辑

In the code snippet you showed me, the event was firing, but you were using $interval instead of setInterval.

在您向我展示的代码片段中,事件正在触发,但是您使用的是$interval而不是setInterval。

$(document).ready(function () {
        $("#closeModal").click(function () {
            $("#modalWindow").modal("hide");
        });
        $("#modalWindow").on('hide.bs.modal', function () {
            console.log("I fired");
            var t = "333";
            self.timer = setInterval(function () {
                checkUpdate();
            }, self.delay, false);
        });
    });

Whenever I'm having problems with events, I always put a console.log at the top of the callback function to make sure it is definitely being fired. 9/10 times it is and its the code in the callback that is crashing.

每当我遇到事件问题时,我总是放一个控制台。在回调函数的顶部登录,以确保它确实被触发。9/10倍,回调中的代码正在崩溃。

#1


2  

The hidden.bs.modal event fires whenever the modal is closed, no matter how you close it. See the docs.

hidden.bs。模态事件在模式关闭时触发,不管你如何关闭它。看文档。

EDIT

编辑

In the code snippet you showed me, the event was firing, but you were using $interval instead of setInterval.

在您向我展示的代码片段中,事件正在触发,但是您使用的是$interval而不是setInterval。

$(document).ready(function () {
        $("#closeModal").click(function () {
            $("#modalWindow").modal("hide");
        });
        $("#modalWindow").on('hide.bs.modal', function () {
            console.log("I fired");
            var t = "333";
            self.timer = setInterval(function () {
                checkUpdate();
            }, self.delay, false);
        });
    });

Whenever I'm having problems with events, I always put a console.log at the top of the callback function to make sure it is definitely being fired. 9/10 times it is and its the code in the callback that is crashing.

每当我遇到事件问题时,我总是放一个控制台。在回调函数的顶部登录,以确保它确实被触发。9/10倍,回调中的代码正在崩溃。