mxui.html.parser
Instantiate widgets from DOMNodes.
Methods
instantiate(list, defaults)
Instantiates, for each DOMNode in list
, the widget defined in its data-mendix-type
property. If a widget has a startup
method defined, it is called as well.
Parameters
Name |
Type |
Description |
list |
Array |
A list of DOMNodes to turn into widgets. |
defaults |
Object |
Default attributes to set on each instantiated widget. |
Returns
Type |
Description |
Array |
The instantiated widgets |
Example
// Create the node to parse.
d = mxui.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.
mxui.html.parser.instantiate([d], {
mxform: this.get("mxform")
});
parse(root, params)
Instantiate widgets from all <div>
nodes under root
that have a data-mendix-type
property (including root
itself).
Parameters
Name |
Type |
Description |
root |
DOMNode |
The node to start parsing from. |
params |
Object |
Default attributes to set on each instantiated widget. |
Returns
Type |
Description |
Array |
The instantiated widgets |
Example
// Create the node to parse.
d = mxui.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.
mxui.html.parser.parse(this.domNode, {
mxform: this.get("mxform");
});