OOP and custom events

OOP and custom events

Hello There,

I am new to JQuery but come from a Flex background, and I am struggling with events in jQuery.

I have the impression that events in jQuery are all bound to the dom. So far all examples I have seen bind to a dom element as in:

  1.  $("p").bind("click", function(e){});
I would like to dispatch and recieve events between OOP style classes as in:

  1. function MyClass() {
  2. $(this).bind("onsend", $(this).recieved);
  3. }

  4. MyClass.prototype.send = function(){
  5. $(this).trigger("onsend");
  6. }

  7. MyClass.prototype.recieved = function(){
  8. alert('recieved');
  9. }

Perhaps this approach is not supported by jQuery. I have used the Yahoo library this way using :
  1.  new YAHOO.util.CustomEvent("onDataChange");
Thanks very much,
Daniel Taylor