title: bootstrap close all open modals prior to opening a new one
body: <p>I have a situation where I'm using a number of modals (for a login form, for a registration form, for a pass retrieval form, etc.) What happens is that if the user clicks "login" and then "register" they'll get two modals on top of each other. I would like bootstrap to be automatically closing all open modals prior to opening a new one. Ideally also wait for the animation.</p>
  
  <p>Has anyone done anything? I have the following solution but I need to target the function every time.</p>
  
  <pre><code>function close_modal() {
      $('.modal').modal('hide')
  }
  </code></pre>
  
  <p>How can I bind this to every modal that opens?</p>
  
  <p>I'm using <strong>Bootstrap v3.3.4</strong></p>