title: Capture the click event on bootbpx confirm/alert box buttons
body: <p>I am trying to create a plugin to capture all the click events on a page. These have confirm and alerts are shown using bootbox plugin. I would like to attach a click event to bootbox confirm/alert buttons (Ex: when clicking on Ok or Yes or No) so that I can capture the click event. I do not want to use bootbox callback events since I do not own the codebase to add the callback events and also I want a common place to capture the clicks. </p>
  
  <p><a href="https://i.stack.imgur.com/CW4uC.png" rel="nofollow noreferrer">bootbox modal dialog</a></p>
  
  <p>Since bootbox confirm/alert are created dynamically, I tried to attach the click event using jquery as below</p>
  
  <pre><code>$(document).on('click', ':button', function(){ 
      alert('bootbox button clicked');
  });
  
  
  $(document).on('click', 'button[type="button"]', function(){
     alert('bootbox button clicked');
  });
  </code></pre>
  
  <p>also tried with class selector as well.</p>
  
  <pre><code>$(document).on('click', '.tempclass', function(){
     alert('bootbox button clicked');
  });
  </code></pre>
  
  <p>tempclass is the class is assiggned to bootbox plugin.</p>
  
  <p>I also tried with javascript attach events as below</p>
  
  <pre><code>document.addEventListener("click", handleClick, false);
  document.attachEvent("onclick", handleClick);
  function handleClick(event)
  {
      alert('bootbox button clicked');
  }
  </code></pre>
  
  <p>But, I was not successful. Every other dynamically created control's click events are getting fired except bootbox button click events. Can somebody please help me on this.</p>