0

I'm using an script to detect internet explorer and display a message. It is not referenced in application.js and I don't want to have it there because it is for one specific page of a controller.

Following this article (§3) http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-3-configuration/, I added in my config/development.rb file the following:

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

Now in my application layout, at the bottom, I have (using haml)

/ [if IE]
      = javascript_include_tag "iealert"

The script is included in 2 places, at the bottom, but also in the header (with javascript_include_tag "application", "data-turbolinks-track" => true), therefore all browsers get the alert since the header inclusion is automatic and not conditional.

What am I doing wrong ?

1 Answer 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 :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.