I am trying to embed a RaphaelJS paper into qooxdoo widget. RaphaelJS is a SVG drawing library for JavaScript, and it needs to bind to a HTML <div>
prior to any drawing.
For that, I call new qx.ui.embed.Html("<div id='raphael'></div>"
) and add it to my widget. After that, I should initialize Raphael by passing the div ID to it.
Problem is that <div id='raphael'>
is not committed to the DOM model (i.e., no real DOM element is created) right after qx.ui.embed.Html()
constructor call. The DOM element creation is indeed deferred until the widget is painted to the screen. I've managed to catch an appear
event for the widget, and, after that, element's existence is guaranteed, and I can initialize Raphael library and do some drawing.
This approach assumes that I have to run all my application logic from within that appear
event handler, which is probably not what I want. Is there any other way to get a widget in its ready-for-drawing state in the main application flow?