jquery - 自动激活嵌入式鼠尾草细胞

标签 jquery html embed sage

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

这是源代码:

<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Sage Cell Server</title>
    <script src="https://sagecell.sagemath.org/static/jquery.min.js"></script>
    <script src="https://sagecell.sagemath.org/static/embedded_sagecell.js"></script>



    <script>$(function () {
    // Make the div with id 'mycell' a Sage cell
    sagecell.makeSagecell({inputLocation:  '#mycell',
                           template:       sagecell.templates.minimal,
                           evalButtonText: 'Activate'});
                           hide: ['evalButton']
    // Make *any* div with class 'compute' a Sage cell

    });
    </script>
  </head>
  <body>


  <h2>Factorial</h2>
  Click the “Activate” button below to calculate factorials.
    <div id="mycell">
@interact
def _(a=(1, 10)):
    print factorial(a)
 </script>
</div>


  </body>
</html>

这是生成的按钮的 html:

<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>

这是按下按钮后的页面(带有单元格):enter image description here

最佳答案

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

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

关于jquery - 自动激活嵌入式鼠尾草细胞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31739053/

相关文章:

c# - SignalR 替换消息队列

javascript - 追加到更改功能

javascript - 使用纯 javascript 或 jQuery 写入日志文件

javascript - 单击后,如何设置事件处理程序以在后续单击时触发?

html - 由于 css 格式化,无法单击某些超链接

javascript - 嵌入式视频显示在照片库顶部

html - 如何用CSS单元素制作镜像效果

css - float-css 重叠在 div 图像旁边

c++ - 如何将 Python 编译成 C++ .exe

javascript - 嵌入的 Flash 对象不会捕捉到 Internet Explorer 上的点击(尽管 wmode)