Custom JavaScript events using the Motionbox EventHandler
04.22.08 - 05:25pm
YUIBlog has a very nice writeup on using custom events to build components.
The Motionbox EventHandler will offer the same capabilities they talk about to the Prototype developer.
The idea here is that you very loosely couple all your components and fire custom events between them to communicate. You do not register callbacks on individual components, rather individual components broadcast interesting events. If another component is interested in that event, it just listens to it.
So:
//Then when that pod gets shown:
MBX.EventHandler.fireCustom($("podElementWithClassOfPod"), "podShown", {iCanBeCustomData: 'anything you want'});
Nothing really has to know about anything else and you can start to assemble your components to form a larger app without worrying about stepping on each others toes (except for event naming conventions).
Speak Your Peace