Reputation: 11247
I am trying to include a separate javascript file to only load on one page in my rails app.
I added a
<%= javascript_include_tag "jumpstart" %>
At the bottom of the page (the page that needs this file).
Unfortunately, my jquery library is loading AFTER my js file loads, so my '$' is undefined.
It looks something like this
Does anyone know a workaround on how I can get the jquery library to load before this custom js file?
Upvotes: 0
Views: 133
Reputation: 115511
use content_for
.
In your layout, after javascript_include_tag 'application
:
<%= yield :scripts%>
In your page:
<% content_for :scripts do %>
<%= javascript_include_tag "jumpstart" %>
<% end %>
Upvotes: 1