Search code examples
javascriptruby-on-railsheadmathjaxturbolinks

Rails 4 Turbolinks not loading MathJax


I have a Rails4 app which uses MathJax. I use MathJax CDN by placing the following line in the <head> section of my app/views/layouts/application.html.erb file:

<script type="text/javascript" src="path-to-mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

More information on: http://docs.mathjax.org/en/latest/start.html#mathjax-cdn

Because of Turbolinks, MathJax loads only on the homepage and won't load on other pages unless I refresh the page (which is not desirable). Instead I want MathJax to load only on /Math/New and Physics/Show pages. What should I do? (I don't want to deactivate turbolinks)

Thanks a lot for your help.


Solution

  • Three great solutions can be found here: http://reed.github.io/turbolinks-compatibility/mathjax.html