title: rails 4 bootstrap 3 ajax modal
body: <p>I'm busy learning Rails 4 and I would like to display a bootstrap popup modal when a user clicks on a link, when the modal opens it needs to show the information relating to that particular record. 
  Heres what I have done so far, which just doesn't show the actual modal popup BUT does pass the correct parameters.</p>
  
  <p>index.html.erb page has:</p>
  
  <pre><code>&lt;%= link_to "view", work_path(w), remote: true, :"data-toggle" =&gt; 'modal', :"data-target" =&gt; '#myModal' %&gt;
  
  &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I also have a works/_modal.html.erb:</p>
  
  <pre><code>&lt;div class="modal-dialog"&gt;
  &lt;div class="modal-content"&gt;
    &lt;div class="modal-header"&gt;
     &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;          &lt;/button&gt;
      &lt;h4 class="modal-title" id="myModalLabel"&gt;&lt;/h4&gt;
    &lt;/div&gt;
    &lt;div class="modal-body"&gt;
    &lt;%= @work.name %&gt;
    &lt;/div&gt;
    &lt;div class="modal-footer"&gt;
      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
      &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>also a works controller: </p>
  
  <pre><code>    def show
      @work = Work.find(params[:id])
      if request.xhr?
      respond_to do |format|
          format.html {render :partial =&gt; 'modal'}
          format.json {head :ok}
      end
  end
  end
  </code></pre>
  
  <p>and finally a works/show.js.erb:</p>
  
  <pre><code>$("#myModal").html("&lt;%= escape_javascript(render 'modal') %&gt;");
  </code></pre>
  
  <p>I hope i'm missing something easy here. in the console I can see the following message so i know it is returning the correct information, but unfortunately it is not showing the modal.:</p>
  
  <pre><code>Started GET "/works/8" for 127.0.0.1 at 2014-03-03 09:31:12 +0000
  Processing by WorksController#show as JS
  Parameters: {"id"=&gt;"8"}
  Work Load (0.2ms)  SELECT  "works".* FROM "works"  WHERE "works"."id" = ? LIMIT 1  [["id", 8]]
  Rendered works/_modal.html.erb (4.9ms)
  Completed 200 OK in 8ms (Views: 6.3ms | ActiveRecord: 0.2ms)
  </code></pre>
  
  <p>Any help on this is greatly appreciated.</p>