Show More
@@ -141,10 +141,17 b' define(["components/underscore/underscore-min",' | |||||
141 | var method = msg.content.data.method; |
|
141 | var method = msg.content.data.method; | |
142 | switch (method){ |
|
142 | switch (method){ | |
143 | case 'display': |
|
143 | case 'display': | |
|
144 | ||||
|
145 | // Try to get the cell index. | |||
144 | var cell_index = this._get_cell_index(msg.parent_header.msg_id); |
|
146 | var cell_index = this._get_cell_index(msg.parent_header.msg_id); | |
145 | this.display_view(msg.content.data.view_name, |
|
147 | if (cell_index == -1) { | |
|
148 | console.log("Could not determine where the display" + | |||
|
149 | " message was from. Widget will not be displayed") | |||
|
150 | } else { | |||
|
151 | this.display_view(msg.content.data.view_name, | |||
146 | msg.content.data.parent, |
|
152 | msg.content.data.parent, | |
147 | cell_index); |
|
153 | cell_index); | |
|
154 | } | |||
148 | break; |
|
155 | break; | |
149 | case 'update': |
|
156 | case 'update': | |
150 | this.handle_update(msg.content.data.state); |
|
157 | this.handle_update(msg.content.data.state); | |
@@ -268,6 +275,14 b' define(["components/underscore/underscore-min",' | |||||
268 | status : function(msg){ |
|
275 | status : function(msg){ | |
269 | that.handle_status(output_area, msg); |
|
276 | that.handle_status(output_area, msg); | |
270 | }, |
|
277 | }, | |
|
278 | get_cell_index : function() { | |||
|
279 | if (that.last_modified_view != undefined && | |||
|
280 | that.last_modified_view.cell_index != undefined) { | |||
|
281 | return that.last_modified_view.cell_index; | |||
|
282 | } else { | |||
|
283 | return -1 | |||
|
284 | } | |||
|
285 | }, | |||
271 | }, |
|
286 | }, | |
272 | }; |
|
287 | }; | |
273 | } |
|
288 | } | |
@@ -277,12 +292,25 b' define(["components/underscore/underscore-min",' | |||||
277 |
|
292 | |||
278 | // Get the cell index corresponding to the msg_id. |
|
293 | // Get the cell index corresponding to the msg_id. | |
279 | _get_cell_index: function (msg_id) { |
|
294 | _get_cell_index: function (msg_id) { | |
|
295 | ||||
|
296 | // First, guess cell.execute triggered | |||
280 | var cells = IPython.notebook.get_cells(); |
|
297 | var cells = IPython.notebook.get_cells(); | |
281 | for (var cell_index in cells) { |
|
298 | for (var cell_index in cells) { | |
282 | if (cells[cell_index].last_msg_id == msg_id) { |
|
299 | if (cells[cell_index].last_msg_id == msg_id) { | |
283 | return cell_index; |
|
300 | return cell_index; | |
284 | } |
|
301 | } | |
285 | } |
|
302 | } | |
|
303 | ||||
|
304 | // Second, guess widget triggered | |||
|
305 | var callbacks = this.comm_manager.kernel.get_callbacks_for_msg(msg_id) | |||
|
306 | if (callbacks != undefined && callbacks.iopub != undefined && callbacks.iopub.get_cell_index != undefined) { | |||
|
307 | var cell_index = callbacks.iopub.get_cell_index(); | |||
|
308 | if (cell_index > -1) { | |||
|
309 | return cell_index; | |||
|
310 | } | |||
|
311 | } | |||
|
312 | ||||
|
313 | // Not triggered by a widget or a cell | |||
286 | return -1; |
|
314 | return -1; | |
287 | }, |
|
315 | }, | |
288 |
|
316 |
General Comments 0
You need to be logged in to leave comments.
Login now