gpt4 book ai didi

javascript - 让 mathjax 在 rpc 之后重新加载页面

转载 作者:行者123 更新时间:2023-11-28 16:04:06 24 4
gpt4 key购买 nike

我只想做这样的事情:

contentAsync.load("linear_regression", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
content.add(new HTML("<h1>FAIL</h1>something went wrong"));
caught.printStackTrace();
}

public void onSuccess(String result) {

// after the RPC new mathematical equations were added to the web content
// so now I invoke the JavaScript function 'testFunc' on the client.
MainLayout.jsniAlert("testFunc");
}
});

JavaScript 部分:

<script type="text/javascript">
function testFunc() {
alert('huhu');
MathJax.... <--! reload page -->
}
</script>

我只需要知道是否以及如何可以告诉 MathJax 重新加载页面..我找不到这样做的例子。我已经尝试过了

        MathJax.Hub.Process();
MathJax.Hub.Update();
MathJax.Hub.Reprocess();
MathJax.Hub.Rerender();

但是没有一个电话能达到我希望的效果。感谢您的帮助

最佳答案

来自MathJax documentation :

To queue the typeset action, use the command

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

This will cause MathJax to typeset the page when it is next able to do so. It guarantees that the typesetting will synchronize properly with the loading of jax, extensions, fonts, stylesheets, and other asynchronous activity, and is the only truly safe way to ask MathJax to process additional material.

The MathJax.Hub.Typeset() command also accepts a parameter that is a DOM element whose content is to be typeset. That could be a paragraph, or a element, or even a MathJax math tag. It could also be the DOM id of such an object, in which case, MathJax will look up the DOM element for you. So

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

would typeset the mathematics contained in the element whose id is MathExample.

关于javascript - 让 mathjax 在 rpc 之后重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15766994/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com