Parse widgets from the DOM.
Methods
# static instantiate(list, defaults) → {Array.<mxui/widget/_WidgetBase>}
Instantiate widgets from a list of HTML elements.
For each element, a widget of the type defined in its data-mendix-type
property is created.
If a widget has a startup
method defined, it is called as well.
Parameters:
Name | Type | Description |
---|---|---|
list |
Array.<HTMLElement>
|
nodes to turn into widgets |
defaults |
Object
|
default attributes to set on each instantiated widget |
instantiated widgets
Array.<mxui/widget/_WidgetBase>
Example
// Create the node to parse.
d = dom.create("div", { "data-mendix-type": "custom.widget.MyWidget" });
// Add it to this widget's DOM.
this.domNode.appendChild(d);
// Instantiate the widget, passing any common attributes for them.
parser.instantiate([d], {
mxform: this.mxform
});
# static parse(root, default) → {Array.<mxui/widget/_WidgetBase>}
Instantiate widgets nested in an element.
For each element in the tree under the root element with a data-mendix-type
property
(including root itself), a widget is created using
instantiate
.
Parameters:
Name | Type | Description |
---|---|---|
root |
HTMLElement
|
the element to start parsing from |
default |
Object
|
attributes to set on each instantiated widget |
instantiated widgets
Array.<mxui/widget/_WidgetBase>
Example
// Create the node to parse.
d = dom.create("div", { "data-mendix-type": "custom.widget.MyWidget" });
// Add it to this widget's DOM.
this.domNode.appendChild(d);
// Instantiate all widgets underneath this widget.
parser.parse(this.domNode, {
mxform: this.mxform
});