I’m using Dojo framework to help me in my Javascript development with cross browsing DOM manipulation and event managing.
For this last I was hoping to use custom event dispatching between objects. But I don’t find anything on this. I read about subscribe/publish, but it not exactly what I want.
Here is what I’d want to do :
var myObject = new CustomObject();
dojo.connect(myObject, 'onCustomEvent', function(argument) {
console.log('custom event fired with argument : ' + argument);
});
var CustomObject = (function() {
CustomObject = function() {
// Something which should look like this
dojo.dispatch(this, 'onCustomEvent', argument);
};
}) ();
Anyone could help me ?
Thanks.
I normally do it this way: (tested with Dojo 1.3.2)