开发者

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开发者_如何学C.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


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜