NodeApi¶
Interface to node objects. The current node object is accessed from js.node
- NodeApi
- .children
- .dom
- .id
- .parent
- .title
- .call(method, params) ⇒
promise - .evaluateLogic() ⇒
boolean - .ready(callback)
- .render() ⇒
NodeApi - .renderChildren(children)
js.node.call(method, params) ⇒ promise¶
| Param | Type | Description |
|---|---|---|
| method | string | method name to call on referenced module |
| params | * | parameters for the method |
Only works on ReferenceNodes. Initiate an async call to the module
behind the refnode. The method being called needs to be bound first on
the receiving module using js.module.bind(). Returns a Promise which
will be resolved with the method’s return value.
js.node.evaluateLogic() ⇒ boolean¶
Run the logic script on this node. Used when implementing a custom renderChildren function, to conditionally render child nodes. Returns true or false, the result of this node’s logic script.
js.node.ready(callback)¶
| Param | Description |
|---|---|
| callback | function to call when node has been rendered. |
Accepts a function that will get called when all descendants of this node have been
rendered. The function context this will be set to this node.
js.node.render() ⇒ NodeApi¶
Method to render DOM of this node. Should only be called within the renderChildren function. See renderChildren for example usage.
js.node.renderChildren(children)¶
Override this method to customize how children are rendered.
| Param | Type | Description |
|---|---|---|
| children | NodeApi | array of child nodes |
This method is passed an array of child nodes which may be
rendered, the resulting child dom appended to this.dom. The array of
rendered children must be returned or else the children of the rendered
children will not be rendered.
This is the default function to use if not overridden:
renderChildren(children){
var rendered_children = []
for (let child of children) {
if(!child.evaluateLogic()) continue;
rendered_children.push(child.render())
}
for (let child of rendered_children) {
this.dom.appendChild(child.dom)
}
return rendered_children
}
See also: