Q:

best practice to inter widget communication in javascript

I have quit a lot of javascript widget and I would like to have a good decoupled way to communicate between them. Something like signals and slots in QT probably? Most of my widgets are written in JQuery using widget factory.
What is the correct way to achieve that, without ending with a spaghetti code?

A:

JavaScript has a built in event system. This gives you an easy way of listening to Events and firing.
You then bind EventListeners to the things you want to listen to (click, myCustomEvent, ...)
When your widget is a pure DOM-enhancing/editing-widget. You will often add eventlisteners to the HTML the widget is enhancing.
Non related widgets could subscribe to the document object that is also a EventTarget thus it can also be used to listen to/fire events.
I tend to often use mootools, thus giving me a powerfull Events mixin in my object. No idea how this is done in jQuery :(

