简体   繁体   English

Mathjax仅在数据表的第一页上呈现

[英]Mathjax render only on first page of the data table

I am using a datatable to show maths questions. 我正在使用数据表来显示数学问题。 The max Equations are added as latex Method. 最大方程式作为乳胶方法添加。 I use the below Js script to render Mathjax equations, 我使用下面的Js脚本来渲染Mathjax方程,

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}

  });

</script>
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full"></script>

but in the datatable the first pagination only shows the correct rendered equations,next all pages are showing the latex. 但是在数据表中,第一个分页只显示正确的渲染方程,接下来所有页面都显示了乳胶。

With jQuery DataTables only first page exist in DOM, that's why pages other than first remain "as is". 使用jQuery DataTables只有第一页存在于DOM中,这就是为什么除了第一页以外的页面保持“原样”。

You need to use drawCallback option to handle table redraw event and re-initialize all custom controls there. 您需要使用drawCallback选项来处理表重绘事件并重新初始化那里的所有自定义控件。 For example: 例如:

$('#example').DataTable( {
    "drawCallback": function( settings ) {
        // MathJax.Hub.Config({
        //    tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
        // });

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

I'm not confident that MathJax.Hub.Config() could be run multiple times but that should give you a start. 我不相信MathJax.Hub.Config()可以多次运行,但这应该给你一个开始。

See MathJax - Configuration for more details on how MathJax could be configured. 有关如何配置MathJax的更多详细信息,请参见MathJax -配置。

UPDATE UPDATE

According to this comment , calling MathJax.Hub.Queue(["Typeset",MathJax.Hub]); 根据这条评论 ,调用MathJax.Hub.Queue(["Typeset",MathJax.Hub]); inside drawCallback solved the problem. 里面的drawCallback解决了这个问题。

LINKS 链接

See jQuery DataTables: Custom control does not work on second page and after for more examples and details. 请参阅jQuery DataTables:自定义控件在第二页上不起作用,之后有更多示例和详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM