[IPython-dev] Widget View post render hook

Jonathan Frederic jon.freder at gmail.com
Sat Mar 15 16:03:48 EDT 2014

Hi Nik,

I'm glad you like the widgets and thank you for the feedback.  I
encountered the same problem when implementing a D3.js widget (see
https://github.com/jdfreder/ipython-d3).  As a hack-ish workaround I used a
timeout with a 0ms interval (
 Right now I don't believe we have a nice way to do this, adding an event
or method is probably a good idea.


On Fri, Mar 14, 2014 at 11:27 AM, Nikolas Tezak <ntezak at stanford.edu> wrote:

> 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.
> Thanks,
> Nik
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140315/55b2349b/attachment.html>

More information about the IPython-dev mailing list