Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Auto Activating Sage Cell

I'm trying to embed a small sage cell/program into my webpage. However, the cell only activates when the user presses a activation button. I would like the cell to show up automatically on the page so the user does not have to press the activate button and then enter the values in for the program. I don't know how I could do this. Is their any way to auto-press a button that is created by a script? Is their any way for just the cell to show up like in Mathematica interactives?

Here is the source code:

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

Here is the html for the button generated:

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

Here is the page after the button has been pressed (with the cell):enter image description here