Twitter Bootstrap 模态,绑定到关闭按钮并获得点击元素

Twitter Bootstrap Modal, bind to close button and get clicked element

使用这个我可以在模式关闭时做一些事情

$(".something").on('hidden.bs.modal', function (e) {
    alert("closed");
});

但是 e 事件不包含有关用于关闭模式的元素的任何信息。当然,它可能不是一个元素,它可能是一个键或单击 'off' 模态。但我仍然想知道单击了哪个元素以隐藏模式,如果有的话。

覆盖关闭按钮上的点击事件只是正确地停止了模态关闭。它会消失,但模态淡入淡出区域仍然存在。

有什么想法吗?

让 Bootstrap 插件事件转发导致它们的底层 originalEvent 是一个已知问题,它将包含在 v4 中。

同时你可以检查这个替代解决方案:

https://github.com/twbs/bootstrap/issues/15408

bootstrap how to detect which button closed a modal dialog on 'hidden_modal_bs' event func?