First off: I’m fairly new to zk. I try to create a component that does a lot of client side processing (think image editing). Therefore, I would like to create a widget that creates it’s own child widgets at ‘construction time’.
But although I do find a lot of documentation on how to instantiate widgets, I fail to find a hint on when to do it. In other words:
How does ZK call my widget, what method should I override in my widget javascript to generate children?
Not sure what’s your purpose for adding child.
But by default the widget initialize lifecycle is
1.widget.$init() //JS widget constructor
2.widget.redraw_ // output html , it’s actually the “mold” .
3.widget.bind_ // binding event to html , and the desktop is inited.
If you are planing to build a composite widget ,
like the calendar in Datebox , you could reference to the $init function in Datebox. 🙂
Let me know if you need further information.
https://github.com/zkoss/zk/blob/5.0/zul/src/archive/web/js/zul/db/Datebox.js