I am using a Dijit Tree, and I need to change the CSS style for a node based on its item property.
The following code fails if the node has not been displayed yet (i.e. node is undefined) :
var node = this.tree.getNodesByItem(item);
if (node[0]) {
domClass.toggle(node[0].domNode, className, add);
}
Is there any event that tells if a node is being displayed/has been created ?
If
nodeisundefinedwhen not yet displayed, that variable should be falsy and thus a simple logical AND (&&) guard within yourif-statement should suffice: