[IPython-dev] Displaying javascript from kernel
Matthias BUSSONNIER
bussonniermatthias at gmail.com
Sat Oct 5 13:48:29 EDT 2013
Le 5 oct. 2013 à 14:38, thwiouz a écrit :
> Hi all,
>
> I'm new in using the notebook and I'm currently trying yo add a button un
> the interface to call the nbtoc magic. I based my function over the one
> given in custom.js .
I don't think what you want is to execute the magic.
You should probably try to convert nbtoc as a pure
js extension that get the js/html using require.js
you can probably find example here :
https://github.com/ipython-contrib/IPython-notebook-extensions
in particular, here:
https://github.com/ipython-contrib/IPython-notebook-extensions/blob/master/slidemode/main.js#L14
you can see how to get other files using require.
> The loading of the magic works but executing it is not. I found something on
> y the web saying that "display_" functions couldn't work because the code
> was not attached to a specific cell.
Yes, because the cell is the thing that handle the display of js and html,
otherwise you have to define your own callback that will get what is
returned by the kernel and append it to the DOM.
> Could someone help me?
For nbtoc the files are usually static, so there is no need to go through the kernel.
I guess it was written like that as a convenience, and because @MinRK prefers magics
That pure js extension.
Making nbtoc a pure-js extension will also allow it to work on non-python notebook.
--
M
More information about the IPython-dev
mailing list