I use the dojo 1.7 version, I want to bind user-defined event, in jQuery I can do like this:
$(window).bind("pushMessage",function(){});
then trigger the event like this:
$(window).trigger("pushMessage",{});
Can dojo get the same result like above? If yes, how?
Yes, it can via
dojo/on:See it in action: http://jsfiddle.net/phusick/MQThM/
There is also
dojo/Eventedwhich provides a class that can be used as a base class or mixin for JavaScript classes that emit their own events. An example from documentation:Also at jsFiddle to play with: http://jsfiddle.net/phusick/ZhG58/