Closed happypeter closed 11 years ago
NOTE!!!
<%= javascript_include_tag "app" %>
<%= yield :scripts %>
make sure app.js
goes before local js, cause Jquery
in app and local js depends on it.
Also, because everything is at the bottom, no need for document.ready()
any more.
Since I need to call rails helper in my jplayer js, so I can not just put it in episodes.js
and use
<% content_for :scripts do %>
<%= javascript_include_tag "episodes" %>
<% end %>
have to use:
<% content_for :scripts do %>
<%= javascript_include_tag "episodes" %>
<script>
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
m4v: "<%= video_url @episode %>",
poster: "http://media.happycasts.net/assets/episodes/stills/load.png"
});
},
swfPath: "/assets/",
supplied: "m4v",
size: {
width: "960px",
height: "720px",
}
});
</script>
<% end %>
Maybe I'll use this http://requirejs.org/
A js snippet for a partial:
content_for & javascript_include_tag
in the partial is the same.so my current solution is just create a editable_comment.js
(for the partial named editable_comment.html.erb1
) under app/assets/javascript
, then require the js in application.js
https://github.com/ruby-china/ruby-china is a great example