Search code examples
javascriptjquerytwitter-bootstrapconfirmation

Bootstrap Confirmation: Detect open and close states?


I am trying to detect when the bootstrap confirmation is opened and closed but I am having no luck with detecting this. I am using an <a> tag to trigger the confirmation (code down below), and trying to detect this is jquery.

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

I originally tried to detect the button click but failed in doing so. It would be better if the confirmation is able to trigger a function once opened and closed.


Solution

  • I ended up finding my answer thanks to the other answers getting me there. The code simply looks at the trigger button which in my case has a class name of delete and then looks for a <div> with the class name popover to see if it is visible or not.

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