tags:

views:

308

answers:

2

Does anyone know how to manually trigger item click event of Dojo tree? I have a create new node button and whenever a new node is created, I would like to move focus to the new node. I have setup the click event and it would be great if I can manually trigger click event with the param is the new node.

A: 

Do you need to send the click event or just set focus?

To set focus you could do:

dojo.byId("myNewNode").focus();
mopoke
Thanks mopoke for fast reply. Actually, I need to set focus to the new node and fire the click event also since I have setup some code in the item click event. The GUI should display the new node as selected.Thanks!
hoangnghiem1711
Ah, OK. You might be able to use document.createEvent but that doesn't work in IE. IE allows you to use a fireEvent method.
mopoke
Yes, I'll give it a try. Thanks!!!
hoangnghiem1711
A: 
var yourtree = dijit.byId("<treeid>");
use dojo.connect(yourtree, "onClick", function(item){
                     <write custom logic here>

});
Rajat