Deal with turbolinks

$document().ready is only called when the DOM completes loading.  Since
turbolinks loads new data into the DOM without completely reloading, the ready
event is never fired.  We can account for this by using the page:load event.
This commit is contained in:
Andrew Tomaka 2014-03-07 02:08:41 -05:00
parent 09b173ca40
commit ae9aecc2ab
3 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
# Place all the behaviors and hooks related to the matching controller here. # Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js. # All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/ # You can use CoffeeScript in this file: http://coffeescript.org/
$(document).ready -> $(document).on 'ready page:load', ->
$("pre code").each (i, e) -> $(".highlight pre code").each (i, e) ->
hljs.highlightBlock e hljs.highlightBlock e

View file

@ -1,7 +1,7 @@
<%= form_for @paste do |f| %> <%= form_for @paste do |f| %>
<div class="form-group"> <div class="form-group">
<%= f.label :content %> <%= f.label :content %>
<%= f.text_area :content, class: 'form-control' %> <%= f.text_area :content, class: 'form-control', rows: 15 %>
</div> </div>
<%= f.submit 'Paste it!', class: 'btn btn-primary' %> <%= f.submit 'Paste it!', class: 'btn btn-primary' %>
<% end %> <% end %>

View file

@ -1 +1 @@
<pre><code><%= @paste.content %></code></pre> <div class="highlight"><pre><code><%= @paste.content %></code></pre></div>