【问题标题】:auto activating embedded sage cell自动激活嵌入式鼠尾草细胞
【发布时间】:2015-10-22 17:06:18
【问题描述】:

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

这里是源代码:

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

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

【问题讨论】:

  • 你能在 jsfiddle 上复制同样的内容吗,jsfiddle.net

标签: jquery html embed sage


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    • 2020-11-24
    • 2021-06-17
    相关资源
    最近更新 更多