diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index cbc2cfa..e61b50c 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -16,7 +16,9 @@ var IPython = (function (IPython) { var key = IPython.utils.keycodes; var CodeCell = function (kernel) { - this.kernel = kernel; + // The kernel doesn't have to be set at creation time, in that case + // it will be null and set_kernel has to be called later. + this.kernel = kernel || null; this.code_mirror = null; this.input_prompt_number = null; this.tooltip_on_tab = true; @@ -48,7 +50,7 @@ var IPython = (function (IPython) { // construct a completer only if class exist // otherwise no print view - if (IPython.Completer != undefined ) + if (IPython.Completer !== undefined) { this.completer = new IPython.Completer(this); } @@ -140,8 +142,14 @@ var IPython = (function (IPython) { return false; }; + // Kernel related calls. + CodeCell.prototype.set_kernel = function (kernel) { + this.kernel = kernel; + } + + CodeCell.prototype.execute = function () { this.output_area.clear_output(true, true, true); this.set_input_prompt('*'); diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 142a193..2a27ebc 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -888,6 +888,14 @@ var IPython = (function (IPython) { var base_url = $('body').data('baseKernelUrl') + "kernels"; this.kernel = new IPython.Kernel(base_url); this.kernel.start(this.notebook_id); + // Now that the kernel has been created, tell the CodeCells about it. + var ncells = this.ncells(); + for (var i=0; i