在我执行了这个命令之后。
bundle exec rake assets:precompile RAILS_ENV=production
现在,jQuery 不再工作了:(
在执行命令之前它一直工作正常。
之后,如果我输入refreshCount();
web 控制台命令行,它会加载函数并且工作正常。
只是 jQuery 部分(document.ready)不再工作了:(
我怎样才能解决这个问题?
资产/javascripts/application.js
...
//= require jquery
//= require jquery-ui
//= require twitter/bootstrap
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require autocomplete-rails
视图/布局/application.html.erb
<%= csrf_meta_tags %>
<%= javascript_include_tag 'application.js' %>
<%= javascript_include_tag 'delete.js.coffee' %>
<%= javascript_include_tag 'bootstrap.js.coffee' %>
<%= javascript_include_tag 'rails.js' %>
<%= javascript_include_tag 'registrations.js.coffee' %>
<%= javascript_include_tag 'tag-it.js' %>
<%= stylesheet_link_tag "application","http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" %>
<%= javascript_include_tag 'reload_count.js' %>
生成的 HTML
<meta content="6Ee26DJl4R+RoEAP8mHpFaqAQkjAn1TtEFmrWXibfk=" name="csrf-token" />
<script src="/assets/application-hh43uu8e5f7e03b516a031d93d.js" type="text/javascript"></script>
<script src="/assets/delete-sj4u7032e3f5d3e60ceuu20c3f5792f.js" type="text/javascript"></script>
<script src="/assets/bootstrap-2b929657252555a21c8fe0915f73.js" type="text/javascript"></script>
<script src="/assets/rails-e69b066913d4a1ff967520b8444026d9.js" type="text/javascript"></script>
<script src="/assets/registrations-c8f90781b38ab1267919654197414382.js" type="text/javascript"></script>
<script src="/assets/tag-it-6bca56a5321c9d3e353987690b24ec8a.js" type="text/javascript"></script>
<link href="/assets/application-13c063e9f4b98571dfe06a1594565bdf.css" media="screen" rel="stylesheet" type="text/css" />
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/assets/reload_count-0cdf66811b7eaff438be9c8b8cc932bf.js" type="text/javascript"></script>
资产/javascripts/reload_count.js
jQuery(document).ready(function() {
refreshCount();
});
function refreshCount() {
$.ajax({
url: "/messages/refresh_count",
type: "GET",
dataType: "script",
});
}