Reputation: 1299
I need to use local instance of MathJax with Rails4 application, but there is problem with turbolinks reloading.
I use mathjax-rails gem (with updated mathjax) for excluding MJ distributive from project directory.
It's require to add gem's route
#routes.rb
mathjax 'mathjax'
and helper in layout
<%= mathjax_tag %>
but when page loads with turbolinks - mathjax doesn't run.
If I call mathjax reload function on page ready()
MathJax.Hub.Typeset();
it will loads in fallback mode - with images instead of fonts.
Then i found another solution, which reloads MathJax with jQuery Ajax. It works perfect with CDN
http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
but when I changed path to local distributive of MathJax
/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML
main mathjax script can't include other js files, because lost dist root path (/mathjax)
And when I set root path manualy with config
root: "/mathjax"
it's loading without errors, but does nothing.
Upvotes: 1
Views: 389
Reputation: 26
This is my solution for Rails4
$(document).on 'page:load', ->
window.MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
Upvotes: 1