jquery - Rails javascript files (other than application.js) not working -
i'm working on implementing jquery rails project, , have javascript tag in head of application.html.erb file:
<%= javascript_include_tag "application" %>
and if set jquery code application.js file, works expected in application. however, if set jquery code other .js files in assets/javascripts folder (home.js, example), doesn't work should in application.
here's application.js file:
//= require jquery //= require jquery_ujs //= require jquery-ui //= require_tree .
it impression lastly line of meant other js files compiled application.js, having <%= javascript_include_tag "application" %> in application.html.erb file sufficient create js files work -- faulty assumption?
these contents of home.js file -- function works should when set application.js file straight when it's in home.js file instead doesn't work.
$(document).ready(function(){ $("h2").click(function(){ $(this).hide(); }); });
try add together //=my home in application.js file above //=require_tree . hope helps.
javascript jquery ruby-on-rails
No comments:
Post a Comment