Nikki Erwin Ramirez Nikki Erwin Ramirez - 2 years ago 180
jQuery Question

Does Dojo have an equivalent to jQuery.trigger()?

In jQuery, you can do this:


How do I do that in Dojo?

Answer Source

I don't think Dojo has similar functionality, at least as not as far as I know / can find. But you can use code like the following to replicate this functionality:

dojo.addOnLoad(function() {

    var button = dojo.byId("myButton");
    dojo.connect(button, "onclick", function() { alert("Clicked!"); });

    // IE does things differently
    if (dojo.isIE)
    { // Not IE
        var event = document.createEvent("HTMLEvents");
        event.initEvent("click", false, true);

A little more verbose, for sure, but you would be able to create your own Dojo version of trigger() with it.

Try it out

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download