引导确认:检测打开和关闭状态



我试图检测何时启动确认打开和关闭,但我没有运气检测到这一点。我使用一个<a>标签来触发确认(下面的代码),并试图检测这是jquery。

<a class="delete" data-toggle="confirmation" title="" data-original-title="Delete Row?">
<i class="fa fa-trash-o"></i>
</a>

我最初试图检测按钮点击,但失败了。如果确认能够在打开和关闭时触发函数,那就更好了。

您可以使用"data-on-confirm"one_answers"data-on-cancel"属性来为这些特定事件注册回调。这些在bootstrap确认插件提供的文档中给出。

<button class="btn btn-default" data-toggle="confirmation" data-singleton="true" data-on-confirm="myAcceptFunction" data-on-cancel="myRejectFunction">Confirmation 1</button>

使用事件,例如:

var modalIsShown = false;
$('#myModal').on('shown.bs.modal', function () {
    modalIsShown = true;
});
$('#myModal').on('hidden.bs.modal', function () {
    modalIsShown = false;
});

http://getbootstrap.com/javascript/modals-events

我最终找到了我的答案,感谢其他答案让我到达那里。代码简单地看触发按钮,在我的情况下有一个类名delete,然后寻找一个<div>与类名弹出窗口,看看它是否可见。

if ($(".delete").next('div.popover:visible').length){
//do something
}

相关内容

最新更新