Is there a standard way in jQuery to publish and subscribe to custom class events? There are countless examples of "custom events" which are always related to some HTML element. But what if the javascript class Person() want's to publish and fire an event iAmSick which is listened for by a class HealthProfessional()? I guess it could be done with callbacks but isn't there something like asEvented?
2 Answers
jQuery is a cross-browser JavaScript library that provides abstractions for DOM traversal, event handling, animation, and Ajax interactions for rapid web development.
So the short answer is: no. Thre is no "standard way in jQuery to publish and subscribe to custom class events".
However, if you want to create your own solution, but don't want to start from scratch, I'd highly recommend that you read Darcy Clarke's article:
1 Comment
Marc
 Thanks, that's certainly pointed me to a wealth of information on the topic. I'd always assumed jQuery, like the retired prototype.js, was more than a DOM manipulator but rather a JavaScript library and enhancer.
  
windowobject to fire all events at it, and bind all event handlers to it... The correspondingeventobject can then contain information about the class that fired the event, etc.