Javascript 让mathjax在rpc之后重新加载页面
我只想做这样的事情:Javascript 让mathjax在rpc之后重新加载页面,javascript,rpc,mathjax,Javascript,Rpc,Mathjax,我只想做这样的事情: 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
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");
}
});
但没有一个电话能达到我希望的效果。
感谢您的帮助:
要将排版操作排队,请使用命令
MathJax.Hub.Queue([“Typeset”,MathJax.Hub])代码>
这将导致MathJax在下一次能够这样做时对页面进行排版。它保证排版将与jax、扩展、字体、样式表和其他异步活动的加载正确同步,并且是要求MathJax处理其他材料的唯一真正安全的方法
MathJax.Hub.Typeset()命令还接受一个参数,该参数是一个DOM元素,其内容将被排版。这可能是一个段落,或一个元素,甚至是一个MathJax数学标记。它也可以是这样一个对象的DOM id,在这种情况下,MathJax将为您查找DOM元素。所以
MathJax.Hub.Queue([“Typeset”,MathJax.Hub,MathExample])代码>
将对id为MathExample的元素中包含的数学进行排版
从:
要将排版操作排队,请使用命令
MathJax.Hub.Queue([“Typeset”,MathJax.Hub])代码>
这将导致MathJax在下一次能够这样做时对页面进行排版。它保证排版将与jax、扩展、字体、样式表和其他异步活动的加载正确同步,并且是要求MathJax处理其他材料的唯一真正安全的方法
MathJax.Hub.Typeset()命令还接受一个参数,该参数是一个DOM元素,其内容将被排版。这可能是一个段落,或一个元素,甚至是一个MathJax数学标记。它也可以是这样一个对象的DOM id,在这种情况下,MathJax将为您查找DOM元素。所以
MathJax.Hub.Queue([“Typeset”,MathJax.Hub,MathExample])代码>
将对id为MathExample的元素中包含的数学进行排版
我是如何实现的(使用Google Web Toolkit):
JavaScript函数:
<!-- Refresh MathJax syntax -->
<script type="text/javascript">
function reloadMathJax() {
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
</script>
如果需要,可以随时调用它:
public void load(final VerticalPanel target,
String file, final Successor success) {
contentAsync.load(file, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
target.add(new HTML("<h1>FAIL</h1>something went wrong"));
caught.printStackTrace();
}
public void onSuccess(String result) {
if (result == null) {
target.add(new HTML(
"Could not load content from server. (RPC returned null)"));
return;
}
HTMLPanel panel = new HTMLPanel(result);
success.onSuccess(panel);
target.add(panel);
EW.reloadMathJax();
}
});
}
公共空隙荷载(最终垂直面板目标,
字符串文件,最终后续文件(成功){
load(文件,新的AsyncCallback(){
失败时的公共无效(可丢弃){
add(新的HTML(“FAILsomething出错”);
已捕获。printStackTrace();
}
成功时的公共void(字符串结果){
如果(结果==null){
添加(新的HTML)(
“无法从服务器加载内容。(RPC返回null)”;
返回;
}
HTMLPanel=新HTMLPanel(结果);
成功.成功(小组);
目标。添加(面板);
EW.reloadMathJax();
}
});
}
我是如何实现它的(使用Google Web Toolkit):
JavaScript函数:
<!-- Refresh MathJax syntax -->
<script type="text/javascript">
function reloadMathJax() {
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
</script>
如果需要,可以随时调用它:
public void load(final VerticalPanel target,
String file, final Successor success) {
contentAsync.load(file, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
target.add(new HTML("<h1>FAIL</h1>something went wrong"));
caught.printStackTrace();
}
public void onSuccess(String result) {
if (result == null) {
target.add(new HTML(
"Could not load content from server. (RPC returned null)"));
return;
}
HTMLPanel panel = new HTMLPanel(result);
success.onSuccess(panel);
target.add(panel);
EW.reloadMathJax();
}
});
}
公共空隙荷载(最终垂直面板目标,
字符串文件,最终后续文件(成功){
load(文件,新的AsyncCallback(){
失败时的公共无效(可丢弃){
add(新的HTML(“FAILsomething出错”);
已捕获。printStackTrace();
}
成功时的公共void(字符串结果){
如果(结果==null){
添加(新的HTML)(
“无法从服务器加载内容。(RPC返回null)”;
返回;
}
HTMLPanel=新HTMLPanel(结果);
成功.成功(小组);
目标。添加(面板);
EW.reloadMathJax();
}
});
}
public void load(final VerticalPanel target,
String file, final Successor success) {
contentAsync.load(file, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
target.add(new HTML("<h1>FAIL</h1>something went wrong"));
caught.printStackTrace();
}
public void onSuccess(String result) {
if (result == null) {
target.add(new HTML(
"Could not load content from server. (RPC returned null)"));
return;
}
HTMLPanel panel = new HTMLPanel(result);
success.onSuccess(panel);
target.add(panel);
EW.reloadMathJax();
}
});
}