title: Dynamically build Twitter Bootstrap modal
body: <p>I am building a Rails application, and I want to place the content from a Rails partial into the modal via AJAX.</p>
  
  <p>In a Twitter Bootstrap 2.3.2 modal, I read via the documentation that you can load content via ajax using the remote key.  </p>
  
  <p><a href="http://getbootstrap.com/2.3.2/javascript.html#modals">http://getbootstrap.com/2.3.2/javascript.html#modals</a></p>
  
  <p>However, this only allows content to be injected into the <code>.modal-body</code>, rather than building the whole modal dynamically.  </p>
  
  <p>Is there a way to build the entire modal, including <code>.modal-header</code>, <code>.modal-footer</code>, dynamically with JS? </p>
  
  <p>It seems very clunky to do this with a string, like follows:</p>
  
  <pre><code>partial = render_to_string(:partial =&gt; 'some-partial').gsub(%{"}, %{'}).gsub(/'/,"\\\\'").gsub("\n", "")
  </code></pre>