title: How to wait for the full load of a bootstrap modal-dialog loaded with jquery .load() function
body: <p>I have severals bootstraps modals in my website, and I load them like this :</p>
  <pre><code>function modal_density(){
      $(&quot;#modal-content&quot;).load(&quot;pages/modals/density_control.php&quot;);
      $('#all_modal').modal('show');
  }
  </code></pre>
  <p>Then I close them like this :</p>
  <pre><code>function close_modal(){
      $(&quot;#modal-content&quot;).empty();
      $('#all_modal').modal('hide');
  }
  </code></pre>
  <p>I want to put focus in an input of my modal, but I think that the modal is not fully loaded when I try to do that :</p>
  <pre><code>function modal_density(){
      $(&quot;#modal-content&quot;).load(&quot;pages/modals/density_control.php&quot;);
      $('#all_modal').modal('show');
      $(&quot;#element&quot;).focus();//&lt;----Added part
  }
  </code></pre>
  <p>How to wait for the full load of my elements ?</p>
  <hr />
  <p>[EDIT]: I tryed this and it doesn't work :</p>
  <pre><code>function modal_controle_densite_valid(){
      $(&quot;#modal-content&quot;).load(&quot;pages/modals/controle_densite_validation.php&quot;, function() {
          $('#all_modal').modal('show');
          $(&quot;#codebarre&quot;).focus();
      });
  }
  </code></pre>
  <p>But the following code is working after 2 sec :</p>
  <pre><code>function modal_controle_densite_valid(){
      $(&quot;#modal-content&quot;).load(&quot;pages/modals/controle_densite_validation.php&quot;, function() {
          $('#all_modal').modal('show');
          setTimeout(function() {$(&quot;#codebarre&quot;).focus()}, 2000);
          //$(&quot;#codebarre&quot;).focus();
      });
  }
  </code></pre>