自动激活嵌入的鼠尾草细胞

Han*_*ach 5 html embed jquery sage

我正在尝试将一个小型贤者单元/程序嵌入到我的网页中。然而,该单元仅在用户按下激活按钮时激活。我希望单元格自动显示在页面上,这样用户就不必按下激活按钮,然后输入程序的值。我不知道我怎么能做到这一点。他们有什么方法可以自动按下脚本创建的按钮吗?他们有办法让细胞显示出来吗?

\n\n

这是源代码:

\n\n
<!DOCTYPE HTML>\n<html>\n  <head>\n    <meta charset="utf-8">\n    <meta name="viewport" content="width=device-width">\n    <title>Sage Cell Server</title>\n    <script src="https://sagecell.sagemath.org/static/jquery.min.js"></script>\n    <script src="https://sagecell.sagemath.org/static/embedded_sagecell.js"></script>\n\n\n\n    <script>$(function () {\n    // Make the div with id \'mycell\' a Sage cell\n    sagecell.makeSagecell({inputLocation:  \'#mycell\',\n                           template:       sagecell.templates.minimal,\n                           evalButtonText: \'Activate\'});\n                           hide: [\'evalButton\']\n    // Make *any* div with class \'compute\' a Sage cell\n\n    });\n    </script>\n  </head>\n  <body>\n\n\n  <h2>Factorial</h2>\n  Click the \xe2\x80\x9cActivate\xe2\x80\x9d button below to calculate factorials.\n    <div id="mycell">\n@interact\ndef _(a=(1, 10)):\n    print factorial(a)\n </script>\n</div>\n\n\n  </body>\n</html>\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是生成的按钮的 html:

\n\n
<button type="button" class="sagecell_evalButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Activate</span></button>\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是按下按钮后的页面(带有单元格):在此输入图像描述

\n

小智 2

隐藏编辑器和 evalButton。不需要 evalButton 文本。将自动评估设置为 true。默认设置为 false。

sagecell.makeSagecell({inputLocation:  '#mycell',
                       template:       sagecell.templates.minimal,
                       hide: ["editor","evalButton"],
                       autoeval: true});
Run Code Online (Sandbox Code Playgroud)