Adithya Puram
Adithya Puram

Reputation: 303

invoke onclick event on a div attached by dojo

I added onclick using dojo to one of my divs

dojo.connect(dojo.byId("button1"), "onclick", function () {
alert('clicked');
}

I now need to call the exact same function dynamically in some other part of Javascript, I tried

dojo.byId("button1").onclick();. 

It did not work. Please help me in resolving this issue.

Upvotes: 0

Views: 2109

Answers (1)

TildalWave
TildalWave

Reputation: 1667

This works for me:

dojo.query("#button1").onclick(function(e){ 
alert('clicked');
})

dojo.byId('button1').click();

Here's a JSFiddle with it.

Upvotes: 1

Related Questions