From 24972e24da0e56128ea6be882361e1527d057517 2012-04-09 22:35:29 From: MinRK Date: 2012-04-09 22:35:29 Subject: [PATCH] document initially hidden javascript container --- diff --git a/IPython/core/display.py b/IPython/core/display.py index 37c6021..9035abd 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -367,6 +367,11 @@ class Javascript(DisplayObject): display function, it will result in the data being displayed in the frontend. If the data is a URL, the data will first be downloaded and then displayed. + + In the Notebook, the containing element will be available as `element`, + and jQuery will be available. The output area starts hidden, so if + the js appends content to `element` that should be visible, then + it must call `container.show()` to unhide the area. Parameters ---------- diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 84055b7..5119461 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -686,13 +686,14 @@ var IPython = (function (IPython) { }; - CodeCell.prototype.append_javascript = function (js, e) { + CodeCell.prototype.append_javascript = function (js, container) { // We just eval the JS code, element appears in the local scope. var element = $("
").addClass("box_flex1 output_subarea"); - e.append(element); + container.append(element); // Div for js shouldn't be drawn, as it will add empty height to the area. - e.hide(); - + container.hide(); + // If the Javascript appends content to `element` that should be drawn, then + // it must also call `container.show()`. eval(js); }