mathjax-rails icon indicating copy to clipboard operation
mathjax-rails copied to clipboard

Turbolinks Compatability

Open samozeleznik opened this issue 10 years ago • 2 comments

This gem does not work with turbolinks by default. Is there a solution for that?

samozeleznik avatar Feb 24 '15 14:02 samozeleznik

now with turbolinks 5 works perfect, the only detail is if you wanna use a config file(not an embed script on the view) you will need to load it after the mathjax_tag method or, a more simple way, do something like this:

$(document).on 'turbolinks:load', ->
    MathJax.Hub.Queue(["Typeset", MathJax.Hub])
    MathJax.Hub.Config
        showMathMenu: false
        tex2jax:
            inlineMath: [[ '$', '$']]

zerocool4u2 avatar Sep 11 '16 19:09 zerocool4u2

I am facing same problem, but it is more complicated. I have a dynamical content on site, which is loaded after mathjax does his job. And i am running turbolinks 5.2.0. Before updating my turbolinks gem i was using two script files

mathjax config

window.MathJax = {
  extensions: ["Safe.js"],
  tex2jax: {
    inlineMath: [ ['$$','$$'], ['$','$'], ['\\(','\\)'] ],
    processEscapes: true
  }

mathjax load config needed for dynamic content (called at the end of page)

if (window.MathJax) {
  MathJax.Hub.Queue(
    ["Typeset",MathJax.Hub]
  );
}

Now when i switch between pages using "back and forward" my mathjax is rendered twice or even more, depending on how ofter i go back and forward. I am sure it is because turbolinks calls mathjax multiple times, but i cant figure out why.

mag2007 avatar Jul 15 '19 12:07 mag2007