title: TypeError: $(...).modal is not a function with bootstrap Modal
body: <p>I have a bootstrap 2.32 modal which I am trying to dynamically insert into the HTML of another view. I'm working with Codeigniter 2.1. Following <a href="https://stackoverflow.com/questions/27022715/dynamically-inserting-a-bootstrap-modal-partial-view-into-a-view">Dynamically inserting a bootstrap modal partial view into a view</a>, I have:</p>
  
  <pre><code>&lt;div id="modal_target"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>as the target div for insertion. I have a button in my view that looks like:</p>
  
  <pre><code>     &lt;a href="#message" class="btn btn-large btn-info" data-action="Message" data-toggle="tab"&gt;Message&lt;/a&gt;
  </code></pre>
  
  <p>My JS has:</p>
  
  <pre><code>$.ajax({
      type    : 'POST', 
      url     : "AjaxUpdate/get_modal",
      cache   : false,
      success : function(data){ 
         if(data){
              $('#modal_target').html(data);
  
              //This shows the modal
              $('#form-content').modal();
         }
      }
  });
  </code></pre>
  
  <p>The button of the main view is:</p>
  
  <pre><code>&lt;div id="thanks"&gt;&lt;p&gt;&lt;a data-toggle="modal" href="#form-content" class="btn btn-primary btn-large"&gt;Modal powers, activate!&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Here is what I'd like to store separately as a partial view:</p>
  
  <pre><code>&lt;div id="form-content" class="modal hide fade in" style="display: none;"&gt;
      &lt;div class="modal-header"&gt;
          &lt;a class="close" data-dismiss="modal"&gt;×&lt;/a&gt;
          &lt;h3&gt;Send me a message&lt;/h3&gt;
      &lt;/div&gt;
      &lt;div class="modal-body"&gt;
          &lt;form class="contact" name="contact"&gt;
               &lt;fieldset&gt;
  
                 &lt;!-- Form Name --&gt;
  
              &lt;legend&gt;modalForm&lt;/legend&gt;
  
              &lt;!-- Text input--&gt;
              &lt;div class="control-group"&gt;
                &lt;label class="control-label" for="user"&gt;User&lt;/label&gt;
                &lt;div class="controls"&gt;
                  &lt;input id="user" name="user" type="text" placeholder="User" class="input-xlarge" required=""&gt;
                  &lt;p class="help-block"&gt;help&lt;/p&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Text input--&gt;
              &lt;div class="control-group"&gt;
                &lt;label class="control-label" for="old"&gt;Old password&lt;/label&gt;
                &lt;div class="controls"&gt;
                  &lt;input id="old" name="old" type="text" placeholder="placeholder" class="input-xlarge"&gt;
                  &lt;p class="help-block"&gt;help&lt;/p&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Text input--&gt;
              &lt;div class="control-group"&gt;
                &lt;label class="control-label" for="new"&gt;New password&lt;/label&gt;
                &lt;div class="controls"&gt;
                  &lt;input id="new" name="new" type="text" placeholder="placeholder" class="input-xlarge"&gt;
                  &lt;p class="help-block"&gt;help&lt;/p&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Text input--&gt;
              &lt;div class="control-group"&gt;
                &lt;label class="control-label" for="repeat"&gt;Repeat new password&lt;/label&gt;
                &lt;div class="controls"&gt;
                  &lt;input id="repeat" name="repeat" type="text" placeholder="placeholder" class="input-xlarge"&gt;
                  &lt;p class="help-block"&gt;help&lt;/p&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
  
  
                  &lt;/fieldset&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
  
      &lt;div class="modal-footer"&gt;
          &lt;input class="btn btn-success" type="submit" value="Send!" id="submit"&gt;
          &lt;a href="#" class="btn" data-dismiss="modal"&gt;Nah.&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I click the button, the modal is inserted correctly, but I get the following error:</p>
  
  <pre><code>TypeError: $(...).modal is not a function 
  </code></pre>
  
  <p>How can I fix this?</p>