thebe icon indicating copy to clipboard operation
thebe copied to clipboard

API function when adding code cells dynamically

Open psychemedia opened this issue 5 years ago • 5 comments

I'm not sure if this is already available and undocumented, or not really supported, but I was wondering if there's a way to activate a new / dynamically added code cell in an already activated web page.

My use case is a simple search engine which indexes separate code and markdown cells. Results are at the cell level. It would be useful to be able to activate a search results page once with a kernel connection, and then as searches are run and code cells added to the listing, provide an option to activate specific code cells.

image

I tried activating cells individually using the following function as the onclick event to the cell level activate button:

var enableThebe = function(selector) {
    thebelab.renderAllCells(`#${selector.parentNode.parentNode.id} code`);
}

and that works to display the thebe run controls:

image

But when I try to run the cell, whilst it posts the Waiting for kernel..., it seems to get no further?

(On the to do list is also support an additional button to "run all previous code cells and current cell".)

psychemedia avatar Oct 25 '20 14:10 psychemedia

Binder can take a long time to spin up. Are you sure binder completed and launched?

moorepants avatar Oct 26 '20 06:10 moorepants

@moorepants Everything worked fine if I listed some results, and then used a simple "Activate" button in the normal way to handle all tagged elements.

psychemedia avatar Oct 26 '20 10:10 psychemedia

Ok, I was just curious about your "Waiting for kernel..." not. It often seems things are going no further because loading a binder image can be slow.

moorepants avatar Oct 26 '20 10:10 moorepants

To @moorepants 's point, it would be helpful if you provide a link to a page that demonstrates this behavior so that others can investigate

choldgraf avatar Oct 26 '20 14:10 choldgraf

@choldgraf I was just fishing for any docs or examples I might have missed and was hoping to pull out a simple repeatable example today, (after first checking I wasn't doing anything obviously wrong), but I was swamped with other stuff today and likely to continue in that vein until next week now.

Broken example is here. An example db needs seeding as per the README; posting a demo db and some test notebooks is on my to do list but I am drowning in "all it takes is five minutes" tasks! I will try to get an example db posted in next day or so to make it easier to try out.

psychemedia avatar Oct 26 '20 20:10 psychemedia