Bootstrap v3模态关闭事件未触发

时间:2021-09-27 11:00:50

I have tried all of the following code, and I cannot get the "hidden" modal event to fire. I have read the documentation, and every other SO question I can find, but still to no avail. I am using rails. Here is the code I have tried:

我已经尝试了以下所有代码,并且无法触发“隐藏”模式事件。我已经阅读了文档,以及我能找到的所有其他SO问题,但仍无济于事。我正在使用rails。这是我尝试过的代码:

$('#signupmodal').on('hide.bs.modal', function() {
alert("hide");
});

$('#signupmodal').on('hidden.bs.modal', function () {
    alert('hidden event fired!');
});

$('#signupmodal').on('show.bs.modal', function (e) {
    setTimeout(function(){
        alert("show");
    }, 300);
});

$(document.body).on('hidden.bs.modal', function () {
    $('#signupmodal').removeData('bs.modal')
});

$(document).on('hidden.bs.modal', '#signupmodal', function (event) {
    alert("hide");
});

Any insight is greatly appreciated!

非常感谢任何见解!

1 个解决方案

#1


0  

I almost don't want to admit this, delete my question and never speak of it again, but turns out jQuery was being loaded twice, and therefore I couldn't access Bootstrap JS.

我几乎不想承认这一点,删除我的问题,再也不说它了,但结果是jQuery被加载了两次,因此我无法访问Bootstrap JS。

Thank you for the help anyway! :)

无论如何,谢谢你的帮助! :)

#1


0  

I almost don't want to admit this, delete my question and never speak of it again, but turns out jQuery was being loaded twice, and therefore I couldn't access Bootstrap JS.

我几乎不想承认这一点,删除我的问题,再也不说它了,但结果是jQuery被加载了两次,因此我无法访问Bootstrap JS。

Thank you for the help anyway! :)

无论如何,谢谢你的帮助! :)