Which JS methods work in a static notebook?


In [1]:
%%javascript 
// Load JS support for Tree Illustrator widgets 
var cell = this;
var ti, ti2;
$.getScript(
    'https://rawgit.com/OpenTreeOfLife/tree-illustrator/master/stylist/ipynb-tree-illustrator.js',
    function() {
        // this function will be called once the IPythonTreeIllustrator module has loaded
        ti = new IPythonTreeIllustrator.IllustratorWidget(cell);
    }
);
alert('hi from %%javascript magic!');



In [2]:
%%javascript
/* NOTE that calls related to an IllustratorWidget created in a previous cell 
 * may fail when a notebook is reloaded. This is because we're outside the 
 * safe callback function, and a (re)loading notebook attempts to evaluate 
 * all cells in quick succession. If these calls fail with a JS error message
 * below, try re-running these cells by pressing Shift-Click.
 */
var ti2 = new IPythonTreeIllustrator.IllustratorWidget(this);  // 'this' is the current cell



In [ ]:
%%javascript
alert(ti);

In [ ]: