I am using rails v6.0.3.2 and ruby 2.7.1. I am putting text in ActionText rich textboxes. My mathjax is not rendered when the page first loads. It is rendered if I refresh the page. I need to either (1) make sure the mathjax renders when the page first loads, or (2) force a page reload. Obviously the former is better.
I read in the mathjax docs here that I can accomplish the former with the following javascript (that I put in my application.js)(but it did not work):
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-MML-AM_CHTML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
In my application.html.haml view I load the mathjax CDN along with some code to enable single dollar sign notation:
:plain
<!-- MathJax -->
<!-- This implements single $ as a delimiter -->
<!-- This MUST come before the CDN reference below -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true}
});
</script>
<!-- Mathjax: latest CDN version -->
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-MML-AM_CHTML">
</script>
How can I enable "dynamic" rendering of mathjax, or, alternatively, force a page refresh when the page first loads?