cells in dynamically added content

56 views
Skip to first unread message

David Farmer

unread,
Dec 12, 2018, 1:51:41 AM12/12/18
to sage...@googlegroups.com

This may be a very basic Javascript question, or maybe it is
in the documentation and I missed it.

I want to dynamically add a sage cell to a page.
But if I just insert an empty div with class sagecell-sage,
it does not get converted into a cell.

Any suggestions, even very basic ones, welcome.

Regards,

David

David Farmer

unread,
Dec 12, 2018, 2:09:46 AM12/12/18
to sage...@googlegroups.com

I should have given more details. What I am actually
doing is changing the class on an existing div.
That is not exactly the same as adding a div with the
appropriate class, but I not sure if it matters.
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/alpine.LRH.2.21.1812120129000.710%40li375-150.members.linode.com.
> For more options, visit https://groups.google.com/d/optout.
>

Andrey Novoseltsev

unread,
Dec 12, 2018, 9:44:55 AM12/12/18
to sage-cell
makeSagecell works once - it goes over the document and converts all specified locations into cells. If new locations matching the same query appear later, you have to call makeSagecell again - it will not affect "old" cells.

If you see a nice place in the documentation to add this (and perhaps better wording) - please do!

Qingping Zheng

unread,
Sep 6, 2021, 3:50:42 AM9/6/21
to sage-cell

Sorry to revive an old thread, I am experiencing an issue with this as well,
despite being able to dynamically add new cells, say with a inputlocation of div.compute, the cells do not seem to link to each other even though devtools shows that they share the same sessionID in networking section as well as the cells being able to evaluate individually. linked is set to true for all the cells

This all happens in one single button click

var div = document.createElement("div");
div.setAttribute("class", "compute");
document.getElementById("cellHolder").appendChild(div);

window.sagecell.makeSagecell({inputLocation: 'div.compute',
                        evalButtonText: 'Evaluate',
                        linked: true});

This is compounded by the fact that returning the results of makeSagecell returns an ever increasing array of cell info's including the older cells who are now of class "compute sagecell output_XXXXXX"

David Farmer

unread,
Sep 6, 2021, 7:15:27 AM9/6/21
to sage-cell

Last I checked, nothing has changed: you can only link cells
which are already on the page when they are initialized.
Newly added cells cannot be linked to existing cells.

That is unlikely to change, because of the same point I have made
on some other recent threads:

The purpose of Sage Cells is to enable an author to allow
computation in a web page they are creating. That goal is
perfectly supported by the current way to link cells.

It is not feasible to turn Sage cells into a fully integrated
computing environment. Attempting to do so will jeopardize
its intended mission, and probably make it impossible to continue
existing as a free service maintained by one part-time person.

If the problem is that the limitations of linking are not well
documented, then please suggest how the documentation can be improved.

Regards,

David Farmer
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-cell+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/1b1f87b2-34a2-4972-bbe7-7e164df9b360n%40googlegroups.com.
>
>

Andrey Novoseltsev

unread,
Feb 20, 2022, 10:21:20 PM2/20/22
to sage-cell
Thanks to the work of Jason Siefken, it should be possible to add cell dynamically - feel free to experiment at http://cosmos.mat.uam.es:8888/ I plan to roll it out to main servers on Tuesday. Documentation: https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst#linked-cells

Ingo Dahn

unread,
Mar 4, 2022, 3:54:22 PM3/4/22
to sage-cell
I managed to add a SageCell dynamically, but how do I link it to the pre-existingsagecells on the page?

David Farmer

unread,
Mar 4, 2022, 4:00:06 PM3/4/22
to sage-cell

Currently it is impossible to link a new cell to existing cells.

Not sure if anyone is working on that.
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-cell+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/99aa0510-78f6-4d3a-9ac6-3dd12ca8041bn%40googlegroups.com.
>
>

Andrey Novoseltsev

unread,
Mar 4, 2022, 4:05:17 PM3/4/22
to sage-cell
It should be possible to do it on the test site now, the public ones are using an older version due to recent problems.

" If you would like to link cells created with different calls to makeSagecell, you can use the linkKey attribute to specify a unique key. All cells initialized with the same linkKey will share a kernel."

Ingo Dahn

unread,
Jun 4, 2022, 11:28:15 AM6/4/22
to sage-cell
What is the status of this effort? Will it allow also to link cells which are embedded into different html pages?

Andrey Novoseltsev

unread,
Jun 4, 2022, 6:46:13 PM6/4/22
to sage-cell
On Saturday, 4 June 2022 at 09:28:15 UTC-6 ingo...@gmail.com wrote:
What is the status of this effort? Will it allow also to link cells which are embedded into different html pages?

It should be up and running, give it a try! The intention was to allow linking of cells that are created using the same JS instance. If you can share the script state between multiple html pages (can one?), then yes. Otherwise no and I don't think it makes much sense to work on it.
Reply all
Reply to author
Forward
0 new messages