Zk: when to create child widget elements?

Firstly: I'm pretty new to zk. I am trying to create a component that handles most of the client processing (think image editing). Therefore, I would like to create a widget that creates its own child widgets at build time.

But although I find a lot of documentation on how to create widgets, I cannot find a hint on when to do this. In other words:

How the ZK calls my widget, which method should I override in javascript of my widget to generate children?

+4
source share
1 answer

Not sure what your goal is to add a child.

But the default widget initialization lifecycle

1.widget. $ init () // JS Widget Constructor

2.widget.redraw _ // output html, this is actually a "mold".

3.widget.bind _ // event binding to html, and the desktop is turned on.

If you plan to create a composite widget, like a calendar in the Date field, you can reference the $ init function in the Date field. :)

Let me know if you need more information.

https://github.com/zkoss/zk/blob/5.0/zul/src/archive/web/js/zul/db/Datebox.js

function _initPopup () { this._pop = new zul.db.CalendarPop(); this._tm = new zul.db.CalendarTime(); this.appendChild(this._pop); this.appendChild(this._tm); } $init: function() { this.$supers('$init', arguments); this.afterInit(_initPopup); this.listen({onChange: this}, -1000); }, 
+5
source