user707711
user707711

Reputation: 261

dojo tree: click events problems

I can't get to click in a tree node. This the script:

 dojo.connect(tree_obj, 'onClick', function(item, node, evt){


                console.log('node: ' +tree_obj.getLabel(node));
                console.log('event: ' +tree_obj.getLabel(evt));
                console.log('identifier: ' + tree_obj.getLabel(item))

            });

this show console log:

 node: undefined
 event: undefined
 identifier: ETD 81

The tree structure:

     root (it's hide)
         node ------> 'undefined' in log on click
            item ----> I can get the label on click

thanks in advance

Upvotes: 0

Views: 3265

Answers (1)

Frode
Frode

Reputation: 5710

and welcome to Stackoverflow.

You cannot do getLabel(evt) or getLabel(node). What did you expect this to return? If you simply want the event or node objects, just use them directly.

dojo.connect(tree_obj, 'onClick', function(item, node, evt)
{
    console.log("Item", item); // This gives you the object in your store
    console.log("Node", node); // This gives you the dijit widget object (UI)
    console.log("Event", evt); // This gives you the event object
    console.log('identifier: ' + tree_obj.getLabel(item)); 
});

Here's an example: http://jsfiddle.net/nZV98/6/

Upvotes: 1

Related Questions