[英]ruby on rails javascript asset path
我对为什么没有指定控制器的js文件感到有些困惑,比如说post.js不会在任何帖子视图中渲染任何Java脚本,例如document.write(“ hello”),而是在application.js之后做到每个视图
Its because in your application.html.erb
you are including application.js
with <%= javascript_include_tag "application" %>
but your controller specified javascripts will render only after the specific action is executed. 这是因为在您的application.html.erb
您将application.js
包含在<%= javascript_include_tag "application" %>
但是您的控制器指定的javascript仅在执行特定操作后才会呈现。 For example if you are creating a new post and your form has remote: true
, After the form is submitted it will trigger the create action which will render create.js.erb
. 例如,如果您正在创建一个新帖子,并且您的表单具有remote: true
,则在提交表单后,它将触发create操作,该操作将呈现create.js.erb
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.