How to reference cell in ipywidgets 7

29 views
Skip to first unread message

Thorin Tabor

unread,
Sep 27, 2017, 8:19:45 PM9/27/17
to Project Jupyter
Hello,

I'm in the process of updating my widget library to ipywidgets 7, and I'm trying to figure out how to get a reference to the Cell object on the Javascript side.

In ipywidgets 6 and earlier I would do something like the following:

const ExampleWidgetView = widgets.DOMWidgetView.extend({
    render
: function () {
       
const cell = this.options.cell;

       
if (cell && cell.metadata && cell.metadata.foo) {
           
// The cell has the metadata flag we're looking for, do one thing when rendering the widget
       
}
       
else {
           
// The cell doesn't have the metadata, do another thing when rendering the widget
       
}
   
}
});

However, in ipywidgets 7 options.cell is undefined. I've been looking through the code and so far haven't seen an obvious alternative for getting a reference to the Cell object. 

Is there another way this can be done?

Thanks!
Thorin
Reply all
Reply to author
Forward
0 new messages