0

我正在使用脚本来检测 Internet Explorer 并显示一条消息。它在 application.js 中没有被引用,我不想在那里,因为它是针对控制器的一个特定页面的。

在这篇文章 (§3) http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-3-configuration/之后,我在我的 config/development.rb 文件中添加了以下内容:

config.assets.precompile += ['iealert.js']

现在在我的应用程序布局的底部,我有(使用haml)

/ [if IE]
      = javascript_include_tag "iealert"

该脚本包含在 2 个位置,在底部,但也包含在标题中(使用 javascript_include_tag "application"、"data-turbolinks-track" => true),因此所有浏览器都会收到警报,因为标题包含是自动的,而不是有条件的。

我究竟做错了什么 ?

4

1 回答 1

1

Maybe something like this:

<%= javascript_include_tag :defaults %>
<!--[if IE]><%= javascript_include_tag "excanvas.min" %><![endif]-->

Rails 3 Conditional Inclusion of Javascript files

Could be wrong though :)

于 2013-10-26T18:35:19.397 回答