How to append DOM elements in notebook?

It would be amazing doing such things below script cells

1 Like

Not sure exactly what you mean, but if you provide HTML, we will actually render it. A good example is the bash notebook I wrote:

I had the same question. When you say “provide”, it seems that you mean the last call has to return an HTML string and it’ll be rendered.

But, it seems one cannot make interactive widgets as event handlers are not in scope. For example:

Hi @sshaw,

Thanks for clarifying, I now understand the question. So what you have to remember is that the code in RunKit is “on the server” while the code in the rendered cell is “on the client”. So, if you want a function to callable there, you need to “send it down” too. The simplest way is to just turn it into a string, like below:

There are fancier techniques you can employ, but this is the basic idea.

1 Like