[IPython-dev] Widget View post render hook

Nikolas Tezak ntezak at stanford.edu
Fri Mar 14 14:27:58 EDT 2014

Hi everybody, 

first of all, I _love_ the widgets, they are extremely useful!! And I’m super impressed by IPython’s crazy fast development progress.
I am currently trying to create a custom widget type that embeds a jsplumb circuit editor
( http://jsplumbtoolkit.com/demo/home/jquery.html )

However, when I implement my custom “render” method for the view I am running into a problem.
I first dynamically create the circuit components (currently just absolutely positioned divs within the widget view’s this.$el div. This works fine.
I then initialize a jsplumb instance and pass this.$el as the default container.
Now, however, when I try to add the connectors and connections with jsplumb within the render method, it fails because jsplumb is trying to read out dynamically the position of the widget view’s div before that div has been inserted into the DOM.

So basically, my problem is that I want code within “render()” that already requires the view to be inserted into the document.
Should I use a different approach, i.e., maybe put this initialization code into "update()”, or do you expect that this will be a common enough use case that it would justify adding a special post render hook that gets called after the view’s div has been attached to a cell's widget sub_area?

I hope I described this well enough, let me know if you’d like me to share a code example.


More information about the IPython-dev mailing list