title: Focus on Input when Bootstrap Modal closes
body: <p>After a blur event on an input field "bootbox1", I want to use  a Bootstrap Modal for an message, after the modal closes the focus would go to the input field "bootbox2". But the input field does not get focus. </p>
  
  <p>What am I doing wrong?</p>
  
  <p><a href="http://jsfiddle.net/barryit99/Lqtuykr2/2/" rel="noreferrer">Demo</a></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;input type="text" id="bootbox" /&gt;
  &lt;input type="text" id="bootbox2" /&gt;
  &lt;div id="myModal" class="modal fade"&gt;
    &lt;div class="modal-dialog"&gt;
      &lt;div class="modal-content"&gt;
          &lt;!-- dialog body --&gt;
          &lt;div class="modal-body"&gt;
              &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;Hello world!&lt;/div&gt;
          &lt;!-- dialog buttons --&gt;
          &lt;div class="modal-footer"&gt;
              &lt;button type="button" class="btn btn-primary"&gt;OK&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>$('#bootbox').on('blur', function checkSelection(e) {
    $("#myModal").on("show", function () { // wire up the OK button to dismiss the modal when shown
      $("#myModal a.btn").on("click", function (e) {
          console.log("button pressed"); // just as an example...
          $("#myModal").modal('hide');
          $('#bootbox2').focus();
          // dismiss the dialog
      });
    });
  
    $("#myModal").on("hide", function () { // remove the event listeners when the dialog is dismissed
      $("#myModal a.btn").off("click");
      $('#bootbox2').focus();
    });
  
    $("#myModal").on("hidden", function () { // remove the actual elements from the DOM when fully hidden
      $("#myModal").remove();
    });
  
    $("#myModal").modal({ // wire up the actual modal functionality and show the dialog
      "backdrop": "static",
          "keyboard": true,
          "show": true // ensure the modal is shown immediately
    });
  
  });
  
  //this works
  $('#bootbox2').on('blur', function checkSelection(e) {
    $('#bootbox').focus();
  });
  </code></pre>